关于javascript:apolloclient-报错-DOMException-The-user-aborted-a-request

最近用umijs,react开发我的项目,后端应用GraphQL技术数据映射,前端应用Apollo Client

问题

1.申请时候总是报错

devScripts.js:6791 Uncaught Error: The error you provided does not contain a stack trace.

Uncaught (in promise) DOMException: The user aborted a request.

  1. 看到这报错一脸懵逼,百度也没有对应的,还是在GitHub @apollo/client官网下issues

解决

<ApolloProvider client={client}></ApolloProvider>

const abortController = new AbortController();
const httpLink = createHttpLink({
  uri: `${LOTTERY_API_URL}/graphql`,
  fetchOptions: {
    mode: 'cors',
    signal: abortController.signal,
  },
});

const client = new ApolloClient({
  cache: new InMemoryCache(),
  link:httpLink,
});

apollo-client文档: https://www.apollographql.com…
参考:https://github.com/apollograp…

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理