Posting permintaan dengan tubuh dan header, async-aak
/**
* Package that needed:
* 'qs', 'axios'
* install by `npm install qs --save
*/
// You can Add more to this
let headers = {
'content-type': 'application/x-www-form-urlencoded',
};
let body = {
field1: 'foo',
field2: 'bar',
};
// For async_await
let reponse = await axios({
method: 'POST',
headers: headers,
data: qs.stringify(body), // <---- This step it is important
url: `${YOUR_URL}`,
});
return response['data'];
Johnmelodyme