Reputation: 425
When I try to set response headers in my service, it converts the json to chinese characters and some other garbage character. I have been trying to debug this issue since 2 days. I am using express server.
Upvotes: 1
Views: 787
Reputation: 30675
I've created a simple test server that sends a basic json response to the client, I don't see the issue with chinese characters appearing. I've also tested with larger json responses.
You might give this a go and see if you're getting the same result.
const express = require('express')
const app = express()
const port = 3000
app.get('/json', (req, res) => {
res.set({ 'content-type': 'application/json; charset=utf-16' });
res.write( JSON.stringify( { foo: 'bar' } ) )
res.end();
})
app.listen(port, () => console.log(`Express listening on port ${port}!`))
Upvotes: 1