Apollo官网的教程如下:
npm install @apollo/client graphql
在载入文件里如下 *** 作
import {
ApolloClient,
InMemoryCache,
ApolloProvider,
useQuery,
gql
} from "@apollo/client";
const client = new ApolloClient({
uri: 'https://48p1r2roz4.sse.codesandbox.io',
cache: new InMemoryCache()
});
client
.query({
query: gql`
query GetRates {
rates(currency: "USD") {
currency
}
}
`
})
.then(result => console.log(result));
会出现如下问题:
解决方案:
const client = new ApolloClient({
uri: 'https://first-sculpin-26.hasura.app/v1/graphql',
cache: new InMemoryCache(),
headers: {
"content-type": "application/json",
"x-hasura-admin-secret":"your x-hasura-admin-secret" ,
}
})
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)