1

尝试查询数据时出现这个长错误。这是有效的数据(针对 GraphQLi 测试)。任何指导将不胜感激!

Error: Network error: Cannot read property 'slice' of undefined
    at new ApolloError (eval at ./node_modules/apollo-client/errors/ApolloError.js (main.js:914), <anonymous>:34:28)
    at ObservableQuery.currentResult (eval at ./node_modules/apollo-client/core/ObservableQuery.js (main.js:826), <anonymous>:83:25)
    at GraphQL.dataForChild (eval at ./node_modules/react-apollo/lib/graphql.js (main.js:2728), <anonymous>:339:62)
    at GraphQL.render (eval at ./node_modules/react-apollo/lib/graphql.js (main.js:2728), <anonymous>:377:33)
    at eval (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:796:21)
    at measureLifeCyclePerf (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:75:12)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:795:25)
    at ReactCompositeComponentWrapper._renderValidatedComponent (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:822:32)
    at ReactCompositeComponentWrapper._updateRenderedComponent (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:746:36)
    at ReactCompositeComponentWrapper._performComponentUpdate (eval at ./node_modules/react-dom/lib/ReactCompositeComponent.js (main.js:2984), <anonymous>:724:10)
4

1 回答 1

-1

我也遇到了同样的问题,希望对你有帮助。在您的 API 响应中,它应该有一个名为“data”的根属性,您的数据应该是这个“data”属性的值。如下所示:

{
    "data": {
        "slice": {
         ...
    }    
}
于 2018-02-03T09:56:47.137 回答