I want to pass body parameters as shown in screen shot (in text/plain format)
我在我的 nodejs/express 项目中使用 axios 。我的请求格式如下图:
var config = {
headers: {
'Content-Length': 0,
'Content-Type': 'text/plain'
}
};
const testInput = (req, res) => {
axios.post('https://api.sandbox.xyz.com/v1/order/new', { firstName: 'Marlon' }, config)
.then(function(response) {
console.log('saved successfully')
})
.catch(function(error) {
console.log(error);
});
};
为此,我怎样才能适当地传递身体参数呢?
var config = {
headers: {
'Content-Length': 0,
'Content-Type': 'text/plain'
},
responseType: 'text'
};
-
responseType
表示服务器将要传输的数据类型
回应
- 选项有 arraybuffer 、 blob 、 document、 json 、 text、stream
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)