[英]how can I implement Bitquery API using GraphQL in react
I am going to implement Bitquery API that uses GraphQL in react.我将实现在反应中使用 GraphQL 的 Bitquery API。 Anybody can help me as soon as possible?
有人可以尽快帮助我吗?
I have tried like that.我试过这样。
const GET_COIN_INFO =
`
{
ethereum(network: bsc) {
dexTrades(
options: {desc: ["block.height", "transaction.index"], limit: 1}
exchangeAddress: {is: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73"}
baseCurrency: {is: "0x2170ed0880ac9a755fd29b2688956bd959f933f8"}
quoteCurrency: {is: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"}
)
{
block {
height
timestamp {
time(format: "%Y-%m-%d %H:%M:%S")
}
}
transaction {
index
}
baseCurrency {
name
symbol
decimals
}
quotePrice
}
}
}
`;
axios.post('https://graphql.bitquery.io', {
query: GET_COIN_INFO,
mode: 'cors',
headers: {
"Content-Type": "application/json",
"X-API-KEY": "BQYl6g3oB7tToSNLRYRsb0jvWVLXiRqh",
'Access-Control-Allow-Origin': '*'
}
}).then(function (response) {
response.status(200)
response.header({
'Access-Control-Allow-Origin': '*',
});
console.log(response);
}).catch(function (error) {
console.log(error);
});
}
I always get CORS error when post axios request.发布 axios 请求时,我总是收到 CORS 错误。 Please help me as soon as possible.
请尽快帮助我。
Access to XMLHttpRequest at 'https://graphql.bitquery.io/' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. CORS 策略已阻止从源“http://localhost:3000”访问“https://graphql.bitquery.io/”处的 XMLHttpRequest资源。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.