I currently trying to download a file via a documenturl using the function below. The download function returns a promise using arrayBuffer(). When run from the front-end I receive no errors, and the arrayBuffer contains the file-data as required. However once I move the function to a .jsw file in the backend, I then receive an error saying that arrayBuffer is not a function. Where am I going wrong? The code is literally the same and the only difference is where it is stored.
import {fetch} from ‘wix-fetch’;
export function downloaddocument(Documenturl) {
//return new promise
return new Promise((resolve,reject)=>{
fetch(Documenturl, {method:'Get'})
.then((data)=>{resolve(data.arrayBuffer())})
. **catch** (error=>{reject(error)});
})
}