2
我試圖使用GraphQL查詢提出POST請求,但它返回錯誤Must provide query string
,即使我的請求在PostMan中有效。使用Graphql查詢節點提取發佈請求
這是我如何讓它在郵遞員運行:
,這裏是我的代碼在我的應用我運行:
const url = `http://localhost:3000/graphql`;
return fetch(url, {
method: 'POST',
Accept: 'api_version=2',
'Content-Type': 'application/graphql',
body: `
{
users(name: "Thomas") {
firstName
lastName
}
}
`
})
.then(response => response.json())
.then(data => {
console.log('Here is the data: ', data);
...
});
任何想法我做錯了什麼?是否可以這樣做,以便我通過fetch
請求傳入的主體屬性被格式化爲Text
,就像我在PostMan請求的正文中指定的那樣?