Expand my Community achievements bar.

"message": "Network error: fetcher is not a function"

Avatar

Community Advisor

I am getting above mentioned error I am using below code snippet to get result from Magento graphql in Node JS:

const gql = require("graphql-tag");
const {ApolloClient} = require("apollo-client");
const fetch = require("node-fetch");
const{createHttpLink} = require("apollo-link-http");
const {InMemoryCache} = require("apollo-cache-inmemory");

const httpLink = createHttpLink({
uri: 'http://localhost:3001/graphql',
fetch: fetch,
});

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

var queryField = `query {
countries {
id
available_regions {
name
code
}
}
}

`;

const query = gql(queryField);
var variables = {};

const result = client.query({
    query,
    variables
  });

I tried with apollo-client 3 as well as 2.

There seems to be issue in getting the results.

1 Reply