我在使用Graphql和Apollo Client时遇到了麻烦.
当我使用REST时,我总是创建不同的响应,如401代码,但在这里我不知道如何做类似的行为.
当我得到响应时,我希望它转到catch函数.我在前面有这个代码:
client.query({
query: gql`
query TodoApp {
todos {
id
text
completed
}
}
`,
})
.then(data => console.log(data))
.catch(error => console.error(error));
Run Code Online (Sandbox Code Playgroud)
有谁能够帮我?