Created
January 9, 2024 19:28
-
-
Save neodigm/033bc49885bd01349b7b057c34b96817 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const oResp = fetch("/uri/", { | |
"body": "IPOID=" + formData.IPOID + "&ProjectID=" + formData.ProjectID, | |
"headers": { "content-type": "application/x-www-form-urlencoded; charset=UTF-8" }, | |
"method": "POST", "mode": "cors", "credentials": "include" | |
}) | |
.then( ( resp )=>{ | |
if( !resp.ok ) throw new Error( resp.status ) | |
return resp.arrayBuffer(); | |
} ) | |
.then( ( buffer )=>{ | |
const elLink = document.createElement("a") | |
const blobFile = new Blob([ buffer ], { type: 'application/pdf' }) | |
const urlFile = URL.createObjectURL( blobFile ) | |
elLink.setAttribute( "href", urlFile ) | |
elLink.setAttribute( "download", sFileName ) | |
elLink.style.visibility = "hidden" | |
document.body.appendChild( elLink ) | |
elLink.click() | |
} ) | |
.catch( ( error )=>{ | |
console.log( "Request Failed: " + error ) | |
} ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment