Download PDF from third party API using forge fetch API

Venkat June 16, 2023

I am using the forge fetch api to get a application/pdf type response content.

The forge fetch api call is as below,


fetch(
            method: 'GET',
            responseType:'application/pdf'
        }
    ).then(async (resp) => {  
        console.log(await resp.arrayBuffer());   // logs "{}" in my console 
    })

resp.arrayBuffer() always return a empty JSON Object rather than a buffer array.
Can someone help me with this?

The Response Headers of the fetch call are
'accept-ranges': 'bytes'
'content-length': '227150'
'content-type': 'application/pdf'

1 answer

0 votes
Stanisław Moska
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 11, 2024

Did you find a solution?

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events