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请求的正文中指定的那样?