[英]No query string was present- GraphQL Javascript
Im doing following query in javscript and GraphQL:我在 javscript 和 GraphQL 中进行以下查询:
const query2 = `
query{
ethereum(network: bsc) {
address(address: {is: "ETHEREUMADDRESSGOSHERE"}) {
balances {
currency {
symbol
address
}
value
}
}
}
}
`;
const url = "https://graphql.bitquery.io/";
const opts = {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-KEY": "APIKEYGOESHERE"
},
body: JSON.stringify({
query2
})
};
fetch(url, opts)
.then(res => res.json())
.then(console.log)
.catch(console.error);
when I run this i get a "No query string was present" error in my console.当我运行它时,我的控制台中出现“没有查询字符串”错误。
I have this query from this site: https://graphql.bitquery.io/ide我从这个网站有这个查询: https://graphql.bitquery.io/ide
and Im using the "All token of a BSC Address" query, in case you want to replicate it.并且我使用“BSC 地址的所有令牌”查询,以防您想复制它。
What is going wrong here?这里出了什么问题? I ran a similliar query before and it worked just fine.
我之前运行了一个类似的查询,它工作得很好。 I was also googling this error, prior to posting that message and all i found in regards to it was the same error in python, but in my case im using javscript so i cnat really use those answers.
在发布该消息之前,我也在谷歌搜索这个错误,我发现的所有关于它的都是 python 中的相同错误,但在我的情况下,我使用的是 javscript,所以我真的使用这些答案。
You can't rename the query variable query2.您不能重命名查询变量 query2。 Replace both instances of "query2" with "query" and it will work.
用“query”替换“query2”的两个实例,它将起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.