H
H
Hiroshima2020-10-31 07:16:36
Node.js
Hiroshima, 2020-10-31 07:16:36

Why did the encoding fail?

When you go to the users/cool page, the encoding flies. (in the vs code editor, the encoding is utf-8).

5f9ce50f23417779587194.png

var express = require('express');
var router = express.Router();

/* GET users listing. */
router.get('/', function(req, res, next) {
    res.send('respond with a resource');
});

router.get('/cool', function(req, res, next) {
    res.writeHeader(200, { 'Content-Type': "text/html; charset = utf-8" });
    res.end('Ты такой крутой\n');
});
module.exports = router;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2020-10-31
@Hiroshima

charset=utf-8so right
And it's better to use .send

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question