How can i interception the http request锛宖or example 401.
Thank you very much.
What I intend to do is intercept all GraphQL queries to check on a common error my server throws for certain reasons, eg: USER NOT FOUND
Then act on it globally in the frontend app.
I am still wondering how to do this, any help? I guess this could be great if written in the Docs also.
Ok thanks I saw this:
import { ApolloLink } from "apollo-link";
import { createHttpLink } from "apollo-link-http";
import { onError } from "apollo-link-error";
import { logout } from "./logout";
const httpLink = createHttpLink({ uri: "/graphql" });
const errorLink = onError(({ networkError }) => {
if (networkError.statusCode === 401) {
logout();
}
});
// use with apollo-client
const link = errorLink.concat(httpLink);
going to give it a try.
@emahuni
import { logout } from "./logout";
Can I see your logout ?
I need to access the Vuex store but unsure.