issue with CardsApi method like listCards and createCards
Ayushjain1997 opened this issue · comments
I am using node js sdk and other api like
try {
const response = await client.customersApi.createCustomer({});
console.log(response.result);
}
in the above code customersApi.createCustomer all the method of customerAPi is working
but in case of cardsAPI
try {
const response = await client.cardsApi.listCards('VD193ZV5V4TZD04WGZ5BDC7SQ0');
console.log(response.result);
} catch(error) {
console.log(error);
}
Actully it is not identified that cardsApi.listcard is method of cardsApi. at the console of my server it shows Cannot read property 'listCards' of undefined
The first element it's expecting is a Cursor, which is why you have this error.
Try
await cardsApi.listCards(undefined, id)
Are you sure you aren't calling:
await client.cardsApi.listCards
You should be calling:
await cardsApi.listCards
Are you sure you aren't calling:
await client.cardsApi.listCards
You should be calling:
await cardsApi.listCards
Actually You are not suppose to understand the problem Please try to use in Your system intgrate node js sdk in your system and send me screen shot if it is working or not
This is my working code:
app.post('/listCards', async (request, response) => {
console.log('Listcards start');
const requestBody = request.body;
try {
const id = requestBody.customerId;
console.log('Customer: ', id)
let result = await cardsApi.listCards(undefined, id)
console.log('Result:')
console.log(result.body);
response.status(200).send(result.body);
} catch (e) {
console.log(
`Listcards [Error] Status:${e.statusCode}, ${e.errors}, Messages: ${JSON.stringify(e.errors, null, 2)}`);
try {
sendErrorMessage(e.errors, response);
} catch (error) {
console.log(`send error message error: ${error.errors}`);
}
}
});
This is my working code:
app.post('/listCards', async (request, response) => { console.log('Listcards start'); const requestBody = request.body; try { const id = requestBody.customerId; console.log('Customer: ', id) let result = await cardsApi.listCards(undefined, id) console.log('Result:') console.log(result.body); response.status(200).send(result.body); } catch (e) { console.log( `Listcards [Error] Status:${e.statusCode}, ${e.errors}, Messages: ${JSON.stringify(e.errors, null, 2)}`); try { sendErrorMessage(e.errors, response); } catch (error) { console.log(`send error message error: ${error.errors}`); } } });
router.post("/ListCards", async function(req,res){
console.log("ayush");
try {
const id = 'QG3B13B45RR5HE2J8XFR97CKW0';
console.log('Customer: ', id)
let result = await cardsApi.listCards(undefined, id)
console.log('Result:')
console.log(result.response);
} catch (err) {
res.json({
status:"false",
Error :err
})
}
})
i used Your code also got same error " Cannot read property 'listCards' of undefined" i think problem is with my account acess token if it is working in Your system then i think it might be possible with the access token
This is my working code:
app.post('/listCards', async (request, response) => { console.log('Listcards start'); const requestBody = request.body; try { const id = requestBody.customerId; console.log('Customer: ', id) let result = await cardsApi.listCards(undefined, id) console.log('Result:') console.log(result.body); response.status(200).send(result.body); } catch (e) { console.log( `Listcards [Error] Status:${e.statusCode}, ${e.errors}, Messages: ${JSON.stringify(e.errors, null, 2)}`); try { sendErrorMessage(e.errors, response); } catch (error) { console.log(`send error message error: ${error.errors}`); } } });
same error got when create card Api is called might be issue with the account