在Babel中更改请求的默认标头
问题描述:
我在Babel中很新,并试图将标题为“Content-Type”的POST请求设置为“application/json”。是否有更改Request
的标题的文档?在Babel中更改请求的默认标头
import Request from 'request-promise-native'
const result = await Request
.post(`some url`)
.auth(authId, secretToken,false)
.form({
text: "hello"
})
console.log(result);
return JSON.parse(result)
答
只需添加一个头的物体,像这样:
.headers({
'Content-Type': 'application/json'
})
是什么'Request'必须做的巴贝尔transpiler? – Bergi