M
M
MonsterAndrew2019-02-18 19:47:57
JSON
MonsterAndrew, 2019-02-18 19:47:57

How can I force Browsersync to be injected into the JSON response of an ExpressJS server?

Hello. I am developing a REST API server using Express. I also use Gulp, Nodemon and Browsersync to speed up development.
What's the problem : Browsersync doesn't want to be injected when I respond with res.json(data). But it works fine when I do this:

res.send("<html><body>" + JSON.stringify(data) +" </body></html>")

I read from the documentation that Browsersync injects the script after the tag <body>, but how do I make it add the script to JSON?
If this is not possible, then what are the other ways to reload the browser page?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question