Graphql响应不是来自Apollo客户端查询

问题描述 投票:0回答:1

在我的本地http://localhost:3000/graphql查询中,如下所示...enter image description here

但是当我通过阿波罗客户端查询时,其响应为空

import {InMemoryCache, gql, ApolloClient, HttpLink} from 'apollo-boost';
const cache = new InMemoryCache();
const client = new ApolloClient({
  cache,
  link: new HttpLink({
    uri: 'http://localhost:3000/graphql',
    credentials: 'same-origin',
  }),
  },
});

client
  .query({
    query: gql`
      {
        brands {
          _id
        }
      }
    `,
  })
  .then(data => console.log(data))
  .catch(error => {
    // its coming in this section
    console.log(error);
  });

不知道我在想什么。任何帮助表示赞赏,谢谢!!!

以下是屏幕截图,当我尝试从前端查询时

enter image description hereenter image description hereenter image description hereenter image description here

graphql apollo react-apollo apollo-client express-graphql
1个回答
0
投票

通过添加app.js解决]

global.FormData = global.originalFormData || global.FormData;

if (window.FETCH_SUPPORT) {
  window.FETCH_SUPPORT.blob = false;
} else {
  global.Blob = global.originalBlob || global.Blob;
  global.FileReader = global.originalFileReader || global.FileReader;
}
© www.soinside.com 2019 - 2024. All rights reserved.