Fetch JSONL file after bulkOperationQuery

ArtMG
New Member
4 0 0

Hello,

I do a "bulkOperationRunQuery" mutation to get a lot of data

Is there a way to use fetch to get the JSONL file present in the url of data.currentBulkOperation.url

I have this error "Failed CORS Request" when i set "cors" in fetch option and response.ok false when i set it to "no-cors"

 

 

async function handleMutation () {
    let mutation = await getOrders({})
    let JsonlUrl = data.currentBulkOperation.url
    const headers = new Headers({
      'Content-Type': 'application/json',
      'Access-Control-Allow-Origin': '*'
    })
    let fetchOptions = { method: 'GET',
      headers: headers,
      mode: 'cors'
    }

    fetch(JsonlUrl, fetchOptions).then(response =>{
      if (response.ok) {
        console.log(response.text())
      } else {
        console.log(response)
      }
    }).catch(error => {
      console.warn('error : ' + error.message)
    })

  }

 

thanks for your help

 

0 Likes
ArtMG
New Member
4 0 0

Anyone can help me on this?

the generated url is in this form

https://storage.googleapis.com/shopify-tiers-assets-prod-us-east1/[...]&response-content-disposition=attachment%3B+filename%3D%22bulk-208308535382.jsonl%22%3B+filename%2A%3DUTF-8%27%27bulk-208308535382.jsonl&response-content-type=application%2Fjsonl. Raison : échec de la requête CORS.

I want to fetch the response-content-disposition filename programatically and parse it.

0 Likes
ArtMG
New Member
4 0 0

So i finally succeeded, to get the file with server side.

 

I created a route with Koa, and get my file downloaded on my nodejs server and return the response in my client side.

0 Likes