模拟邮递员请求进入 Axios? [英] Mock Postman request into Axios?
本文介绍了模拟邮递员请求进入 Axios?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试构建我的 axios
以便能够模仿邮递员的请求,但失败了.请帮忙看看
I'm trying to construct my axios
to be able to mimic the postman request but failed. Please help to have a look
const ax = axios.create({
timeout: 30000,
headers: {
'content-type': 'application/x-www-form-urlencoded'
}
});
// Attempt register operation
ax.post('https://url/5bc9ff9628d79b6d274165da/update.json', {
body: JSON.stringify({
json: JSON.stringify({ "stat": "Delivered" })
})
})
.then(({ data }) => {
console.log('DEBUG::success!!! data::', data);
})
.catch((err) => {
console.log('DEBUG::err', err);
});
推荐答案
您可以使用 Postman 中的代码生成功能.
You can make use of the code-generation feature in Postman.
单击代码(保存按钮下方)> 搜索Axios"> NodeJS - Axios
Click on Code (below Save button) > Search for 'Axios' > NodeJS - Axios
在 Postman 中生成代码的文档:https://learning.getpostman.com/docs/postman/sending_api_requests/generate_code_snippets/
Docs for code generation in Postman: https://learning.getpostman.com/docs/postman/sending_api_requests/generate_code_snippets/
这篇关于模拟邮递员请求进入 Axios?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文