1

I use XMLHttpRequest in Node.js and when handling request in server.js (asynchronous POST request) I use this code:

      const filePath = './input.pdf';
      fsPromises.readFile(filePath)
        .then(res => {
          const pdfBytes = new Uint8Array(res).buffer;
        })
        .catch(err => {
          console.log('Could not read file-template');
        });

then I get ArrayBuffer through this code. But I want to move this code into module and call export function there with this code. This change disrupted reading file and devtools network returns error in my request with message 'Provisional headers are shown'.

How can I make it work in module, not in server.js?

I attached images with messages in devtools img1, img2

2
  • From the attached screen shot, it looks like a CORS error - not sure that it has to do with the actual location of the function (module or server.js) Commented Jan 15, 2023 at 14:17
  • Yes, it looks like module isn't permitted to appeal to the file Commented Jan 15, 2023 at 14:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.