2017-08-16 71 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' 
})