Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

344
Views
How to download a file when I have the raw file data in React?

I have been battling with this one issue for about two days now and don't have any solution. I get data back from an API on our old system with regards to Attachments and other data. Now if I run the query in postman, I get the actual document showing up. Now in VS Code, I do the call on the backend in Nodejs and send that data to my frontend, which when I log it to the console gives me the raw data of the file:

%PDF-1.6

%���� 199 0 obj <</Linearized 1/L 891424/O 201/E 139951/N 6/T 887396/H [ 1236 433]>> endobj

xref 199 47 0000000016 00000 n 0000001669 00000 n 0000001936 00000 n 0000002504 00000 n 0000002546 00000 n 0000002684 00000 n 0000002821 00000 n 0000002959 00000 n 0000003072 00000 n 0000004421 00000 n 0000005810 00000 n 0000006352 00000 n 0000006822 00000 n 0000006961 00000 n 0000007241 00000 n 0000007503 00000 n 0000007529 00000 n 0000008087 00000 n 0000010099 00000 n 0000010543 00000 n 0000010810 00000 n 0000012804 00000 n 0000014560 00000 n 0000016676 00000 n 0000019142 00000 n 0000021085 00000 n 0000030182 00000 n 0000041511 00000 n 0000050173 00000 n 0000059390 00000 n 0000059493 00000 n 0000059770 00000 n 0000059839 00000 n 0000060279 00000 n 0000119811 00000 n 0000121391 00000 n 0000123466 00000 n 0000126935 00000 n 0000129729 00000 n 0000131785 00000 n 0000133109 00000 n 0000135857 00000 n 0000138698 00000 n 0000139745 00000 n 0000139808 00000 n 0000139882 00000 n 0000001236 00000 n trailer <</Size 246/Prev 887384/Root 200 0 R/Info 198 0 R/ID[<8D8F16B67F948647AA1C78C6338DE7E5><623F133706D1C94384C1BFBFEFB70137>]>> startxref 0 %%EOF

245 0 obj<</Length 351/Filter/FlateDecode/I 420/S 260>>stream x�bb����� � bÁ+P���#�8���^�y���3�� RZ��_[ 6�Z��Q�֋m��=wX�˖�

What I need help with is in my callback function....how do I get this data in a format where I can just immediately download it with the correct file structure showing. I have really tried quite a few options and nothing seems to work.

Any advice would be greatly appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use js-file-download library:

import fileDownload from 'js-file-download';

fileDownload(downloadData, fineName);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!