我照视频中教的配置client但是
浏览器抛错:
Uncaught SyntaxError: Unexpected string (at @apollo_client.js?v=de6dd3f3:1377:51)
配置如下:
import { ApolloClient, InMemoryCache } from '@apollo/client';
export const client = new ApolloClient({
uri: 'http://localhost:3000/graphql',
cache: new InMemoryCache(),
});
export default client;
使用场景
client
.query({
query: FIND,
variables: {
id: '6dbf878b-f0d8-4b81-b35c-7652f01ad719',
},
})
.then((result) => console.log(result));
这样写是看了apollo官方文档为了排查问题写的,位置在main.tsx中
服务器测试可用
平台级应用+流行全栈技术+实用职场技巧&面试策略 助你升职加薪
了解课程