📌  相关文章
📜  axios 获取请求正文 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:16.808000             🧑  作者: Mango

代码示例3
/**
 * 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'];