score:0
Instead of sending buffer to the front end try this.
Front end -
download2016(){
window.open("http://localhost:5000/download/report/2016")
}
Backend Code -
const router = require('express').Router();
const fs = require('fs');
const path = require('path');
router.get('/report/2016',function(req, res){
var tempfile = __dirname + '\\mypdfname.pdf';
res.download(tempfile, function(err) {
if(err) {
console.log('Something went wrong : ', err)
} else {
console.log('File downloaded.')
}
});
});
module.exports = router;
Source: stackoverflow.com
Related Query
- How to open a PDF download into a new tab when calling a GET function from React frontend?
- I'm trying to download a pdf file from a node server to a react client but when I open it, it shows blank
- React Webpack. Why do I get an error when calling a function from a child component?
- Brand new to react and confused on how I omit an item from a function and also inject a button into my grid
- How to update state of child component when it get called in map function from parent component React JS
- How to open a new tab from a react front-end app
- How to get updated ID from array when calling set state in React
- How to open a pdf in new tab in reactjs?
- How to get value from a react function within a react component
- How can I get data from a local file into my React app?
- How do I get my React TextField to open the number pad when inputting on a mobile device?
- How can I open an external link in new tab in react native?
- How do I link my javascript files in react when converting from HTML,CSS,JS into JSX, CSS, JS?
- How do I Prevent Opening in New Tab When Dragging Image/s in Div in React
- How to push values into state by calling single onChange function - react
- How do I combine two arrays in react to get a new one with all of the items from the previous two?
- How to download pdf from puppeteer using Nest js as Server Side and React in Client Side?
- browser says " request has been blocked by CORS policy" when calling to a spring boot get method from react js using axios
- How to get function from parent component in React
- How to get notified when moving back from React component?
- How to dynamically get the images from database into react carousel?
- How do I create a class decorator for mixing new methods into a React component when using Typescript?
- How to Download Pdf File in React From Api
- How to avoid react date picker calendar to open on tab keypress from previous textbox
- How do I get the new updated data from react hooks or useEffect?
- How to prevent to open new tab when I drag and drop image on the Chrome browser in JavaScript?
- In React JS, how to get value from multiple input fields when one of them is changed
- How to open some child links in new tab in React
- react js, when open page Other than home in new tab show 404
- How to get element from array in new line? react
More Query from same tag
- How to pass data from vanilla JavaScript to React functional component
- How to update react swiper when orientation change?
- How to use locale in material ui datepicker (MuiPickersUtilsProvider)?
- How to show dummy image in React when url is broken?
- React Drag n Drop PUT request after props
- Building a select option dropdown: Objects are not valid as a React child
- Difference between React Component and React Element
- Mapping checkbox id's to return related properties
- How to build a side toggle menu respond to header menu in React
- React/TypeScript: How should I handle this style of component composition?
- Server sent events being multiplicated when incoming to React
- IE11: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object
- Fetch foreign key object instead of ID in React from Django API
- Testing React Components setState overload which takes a function
- How to access array value in react?
- How to add animate to the alphabets inside a react carousal?
- Can't access API in react
- Cordova Android ReactJS
- Trigger onClick function from within conditional content
- Duplicate string index signature.ts(2374)
- How to properly update redux state with a boolean value?
- pagination logic in calculating total of pages
- Nested React/Relay component not receiving props
- AWS amplify datastore wont synchronise with server
- Gathering Material-UI components in one file
- <NavLink /> doesn't trigger @@router/LOCATION_CHANGE action
- React devtools while developing a Microsoft add-in
- react-bootstrap-table-next: minimum required column width
- Blocked by CORS policy : No 'Access-Control-Allow-Origin' header is present on the requested resource
- pass an array of objects to a dropdown (select) using typescript