# How to fetch products from GraphQL

**URL:** <https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190>\
**Category:** GraphQL API\
**Created:** [October 7, 2022, 8:27am UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190 "2022-10-07T08:27:53Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![TopCodeBeast](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@TopCodeBeast](https://community.shiphero.com/u/TopCodeBeast)\
**Post date:** [October 7, 2022, 8:27am UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190/1 "2022-10-07T08:27:53Z")

</div>

I want to fetch products data with GraphQL on JS.  
I tried below examples from tutorial and I got network error happens.  
Could you tell me what is the reason?

import { GraphQLClient} from ‘graphql-request’

async function main() {  
const endpoint = ‘[https://public-api.shiphero.com/graphql](https://public-api.shiphero.com/graphql)’

const graphQLClient = new GraphQLClient(endpoint, {  
headers: {  
authorization: ‘Bearer TOKEN’,  
},  
})

const query = /\* GraphQL \*/ `{ products { request_id complexity data(first: 10) { edges { node { id sku } } } } } `

const data = await graphQLClient.request(query)  
console.log(JSON.stringify(data, undefined, 2))  
}

---

<div class="post-metadata">

**Author:** ![sh-agent](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@sh-agent](https://community.shiphero.com/u/sh-agent)\
**Post date:** [October 7, 2022, 11:20am UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190/2 "2022-10-07T11:20:35Z")

</div>

Hey @TopCodeBeast,

Thanks for reaching out!  
Going to look into this now. Does that by chance return a request id at all?

Please let me know if you have any questions or concerns!

Best,  
RayanP

---

<div class="post-metadata">

**Author:** ![TopCodeBeast](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@TopCodeBeast](https://community.shiphero.com/u/TopCodeBeast)\
**Post date:** [October 11, 2022, 12:50am UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190/3 "2022-10-11T00:50:49Z")

</div>

I think the problem maybe Token related.  
I just change Token instead of ‘Bearer Token’  
headers: {  
authorization: ‘Bearer TOKEN’,  
},

Error is like this:  
browser-ponyfill.js:480 Uncaught (in promise) TypeError: Network request failed  
at xhr.onerror (browser-ponyfill.js:480:1)

---

<div class="post-metadata">

**Author:** ![sh-agent](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@sh-agent](https://community.shiphero.com/u/sh-agent)\
**Post date:** [October 11, 2022, 7:49pm UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190/4 "2022-10-11T19:49:15Z")

</div>

Hey @TopCodeBeast,

We’re not familiar with how JS handles errors, would it be possible for you to share the actual response you got from us, along with the request id?

Please let me know if you have any questions

---

<div class="post-metadata">

**Author:** ![TopCodeBeast](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@TopCodeBeast](https://community.shiphero.com/u/TopCodeBeast)\
**Post date:** [October 28, 2022, 9:32am UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190/5 "2022-10-28T09:32:41Z")

</div>

Can you show me one of your developers contact?

---

<div class="post-metadata">

**Author:** ![sh-agent](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@sh-agent](https://community.shiphero.com/u/sh-agent)\
**Post date:** [October 28, 2022, 7:41pm UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190/6 "2022-10-28T19:41:59Z")

</div>

Hey @TopCodeBeast,

Happy Friday and thanks for hanging in there.

I believe there is a slight misunderstanding. The Developer Community is a forum where our clients developers can ask, answer, and search for questions. Unfortunately, there are no ShipHero Developers here, just our Public API Specialists that maintain this forum.

If you can send us the response and request id, we’ll do our best to troubleshoot your issue!

Please let me know if you have any questions or concerns.

Best,  
RayanP

---

<div class="post-metadata">

**Author:** ![TopCodeBeast](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@TopCodeBeast](https://community.shiphero.com/u/TopCodeBeast)\
**Post date:** [November 7, 2022, 12:33am UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190/7 "2022-11-07T00:33:36Z")

</div>

Can you try to make a guide for fetch Data in JS?

---

<div class="post-metadata">

**Author:** ![TopCodeBeast](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@TopCodeBeast](https://community.shiphero.com/u/TopCodeBeast)\
**Post date:** [November 21, 2022, 7:18am UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190/8 "2022-11-21T07:18:43Z")

</div>

I found the reason,  
It is making Cors error on my local.  
I tried on postman and it is working well.

const shipHeroApi = Axios.create({  
baseURL: ‘[https://public-api.shiphero.com](https://public-api.shiphero.com)’,  
headers: {  
‘Accept’: ‘_/_’,  
‘authorization’:  
‘Bearer MY\_Token’,  
},  
data: {  
‘query’: `{ products { data(first: 10) { edges { node { id sku } } } } }`,  
},  
});

---

<div class="post-metadata">

**Author:** ![TopCodeBeast](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@TopCodeBeast](https://community.shiphero.com/u/TopCodeBeast)\
**Post date:** [November 22, 2022, 7:11am UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190/9 "2022-11-22T07:11:04Z")

</div>

When I fetch products on postman, it is nothing to show.  
The products only show that I posted on Ship Hero hosting?

---

<div class="post-metadata">

**Author:** ![sh-agent](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@sh-agent](https://community.shiphero.com/u/sh-agent)\
**Post date:** [November 22, 2022, 8:20pm UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190/10 "2022-11-22T20:20:43Z")

</div>

Hey @TopCodeBeast,

Would you mind sending the request id for that call?

Please let me know if you have any questions or concerns!

Best,  
RayanP

---

<div class="post-metadata">

**Author:** ![TopCodeBeast](https://avatars.discourse-cdn.com/v4/letter/t/a87d85/32.png) [@TopCodeBeast](https://community.shiphero.com/u/TopCodeBeast)\
**Post date:** [November 23, 2022, 2:00am UTC](https://community.shiphero.com/t/how-to-fetch-products-from-graphql/2190/11 "2022-11-23T02:00:21Z")

</div>

```
{
			products {
			         request_id,
	        data(first: 10) {
					edges {
						node {
							id
							sku
						}
					}
				}
			}
		}

```

This is query and my request Id is “637dc7dd2a2f39d276f69ff5”

This is result

```
"data": {
    "products": {
        "request_id": "637dc7dd2a2f39d276f69ff5",
        "data": {
            "edges": []
        }
    }
},
"extensions": {
    "throttling": {
        "estimated_complexity": 11,
        "cost": 1,
        "cost_detail": {
            "products": {
                "items_count": 0,
                "cost": 1,
                "total_cost": 1,
                "fields": {}
            }
        },
        "user_quota": {
            "credits_remaining": 2001,
            "max_available": 2002,
            "increment_rate": 30
        }
    }
}

```
