Shopify GraphQL API - Unexpected end of file

Hi everyone!

I’m doing some request with Shopify GraphQL API, and I have an error that I dont know how to fix.

import axios from "axios"

// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
  async run({ steps, $ }) {

    const response = await axios.post(
        'https://*************.myshopify.com/admin/api/2022-10/graphql.json',
        {
          query: `
            query { 
              products(first: 100 query:"status:'active' tag:'analyse_vhs'") { 
                edges { 
                  node {
                    id
                    title           
                  } 
                } 
              } 
            }`
        },
        {
            headers: {
                "Content-Type": "application/json",
                'X-Shopify-Access-Token': '*******************'
            }
        }
      )
    return response;
  },
})

I’m making a request to get a list of products, sometimes that works well but mostly I got this error

image

Is there from Pipedream, Axios or Shopify?

Hello @victorheliosweb, may I ask is there any changes in the code from the execution that’s success & the execution that’s failed?

Also could you use Pipedream’s axios instead? This version of axios works better with Pipedream

Hello @vunguyenhung,

No, I have a cron every 2 hours, and sometimes that’s success.

I’m looking on your link, I didn’t find how make a post request. Is there more documentation for Pipedream’s axios?

Hello @victorheliosweb, I think you could try this:

import { axios } from "@pipedream/platform"

// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
  async run({ steps, $ }) {

    const response = await axios($, {
        method: 'POST',
        url: 'https://*************.myshopify.com/admin/api/2022-10/graphql.json',
        data: {
          query: `
            query { 
              products(first: 100 query:"status:'active' tag:'analyse_vhs'") { 
                edges { 
                  node {
                    id
                    title           
                  } 
                } 
              } 
            }`
        },
        headers: {
            "Content-Type": "application/json",
            'X-Shopify-Access-Token': '*******************'
        }
    })

    return response;
  },
})
2 Likes

Hello @vunguyenhung,

Yesterday I change the ‘const’ variable for ‘let’ or a direct return and everything works well during the night.

It seems there is a conflict between workflow when I use ‘const’ and the same variable name.

Also I’ll try with your method and pipedream/plateform, thank a lot!