Wednesday, 4 January 2017

Express.js Response Question

Hello all!I'm writing a simple front-end react app served on an express backend. The base route for the app ('/') serves the client-side react bundle and then routing is done client-side with react router. IE:app.get('/', (req, res) => { res.sendFile(path.resolve(__dirname, '../frontend/dist/index.html'))}) I also have a '/pictures' route which at the moment should just send back a html/text response of 'Picture'. Like this:router.get('/pictures', (req, res) => { res.type('html') res.status(200).send('picture') }) Only when I send a GET request to this '/picture' route, the response body is a ReadableStream and not the text. Any ideas why this is?

Submitted January 04, 2017 at 12:56PM by ajc820

No comments:

Post a Comment