2017-08-16 68 views
0

我在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) 
+0

是什么'Request'必须做的巴贝尔transpiler? – Bergi

回答

0

只需添加一个头的物体,像这样:

.headers({ 
    'Content-Type': 'application/json' 
})