Hi everybody,
I would like to retrieve a user’s bank card list from the /user/{id}/cards route of my API. I was very successful in creating the smart relationship like this:
router.get('/user/:userId/relationships/cards', async (request, response, next) => {
let requestOuranos = await axios.get(process.env.API_APP_URL + '/' + process.env.API_VERSION + '/user/' + request.params.userId + '/cards', {
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + process.env.API_SECRET
},
responseType: 'json'
}).then((result) => {
return {
status: result.status,
data: result.data
};
}).catch((error) => {
return {
status: error.response.status,
data: error.response.data
};
});
});
I get a json format like this :
[
{
id: 'card_1InRlOGhSnPh1ys0y5En3GrT',
name: 'Ma CB',
default: true,
last4: '4242',
expireMonth: 4,
expireYear: 2024
},
{
id: 'card_1InRpPGhSnPh1ys0XUtDkZaI',
name: 'Mon AMEX',
default: false,
last4: '0005',
expireMonth: 5,
expireYear: 2045
},
{
id: 'card_1InRoHGhSnPh1ys0mJxwAGwy',
name: 'Ma CB Pro',
default: false,
last4: '4444',
expireMonth: 4,
expireYear: 2024
}
]
I tried to return the json a little bit like this :
return response.send(json);
Obviously this does not work :’)
Can someone say me how to format and simply return this json ?
Thank’s