Что не так с кодировкой при отправке GET запроса?
Делаю проект сервера для обмена данными в виде json. Тут встала загвоздка. Почему у меня не совпадает кодировка? Также было бы интересно, какие в этом коде у меня ошибки?
[{works: [titleOfWork: "Название работы 1",cost: 0}],_id: "5f2e92e98d97391c7f4ea137",title: "Газ(САЗ)"}]
Код роутера home.js
const {Router} = require('express');
const Cars = require('../models/Car');
// const Work = require('../models/Works');
const router = Router();
router.get('/', async (req, res) => {
console.log('GET', '/', `status: ${res.statusCode}`);
const cars = await Cars.find({});
res.end(JSON.stringify(cars))
});
module.exports = router;
index.js
const express = require('express');
const mongoose = require('mongoose');
const app = express();
const homeRoutes = require('./src/routes/home');
app.use(homeRoutes);
async function start() {
try {
await mongoose.connect('mongodb://localhost:27017/cars', {
useNewUrlParser: true,
useUnifiedTopology: true
});
app.listen(3000, () => {
console.log('Server started in port: 3000');
});
} catch (e) {
console.log(e, new Date());
}
}
start();
А это код модели Car.js
const {Schema, model} = require('mongoose');
const schema = new Schema({
title: {
type: String,
required: true
},
works: {
type: Array,
required: true
// ref: 'Work'
}
});
module.exports = model('Car', schema);