Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

"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