I'm try using Post method in axios to send some data, but the result of my code only undefined. This is my code to post http request using axios:
const Axios = use('axios');
const Env = use('Env');
const querystring = require('querystring');
class getTrackingData({ response }) {
const tracking = await Axios.post(Env.get('APP_ENDPOINT') + '/waybill',
{
data: querystring.stringify({
waybill : 'SOCAG00183235715', courier : 'jne'
})
},
{
headers: {
'key':Env.get('APP_KEY'),
'content-type': "application/x-www-form-urlencoded"
}
}).then(function(response) {
console.log(response.data);
//return response.data;
});
return tracking;
}
}
What's wrong with this code?