I have trying to use JSON type in my node js application but i am getting data in some data of scripted type.
my response }, data: '\x1F�\b\x00\x00\x00\x00\x00\x00\x00]PMo�0\f�-�ykӬ_ ��\n' + '(\x14�\x1AVi�K\x15�\x00�4�\x14\x01���RN\x13��z�{~���\taJ�Z����\x16\x00�\x10�>�5rç\x18�c���\x1D:�ɓ���y5[\x15�N��\V����Eq�SyD�\ff� ށ\x07�\x1C\x7F|Wiw�f�M��%����&[���↸��\t���J(�\x05ae�r��u���c�x���(;�\n' + '\x0B��\x17����3��-a6�u/A�\x115S�aĩ��p�8N\r���\x1D\x02�ə�qj��(��aF3a�em�A���\x12k\x03�A0�a\x04#\x1F\x00��T�\x17XwmO �5C��nV��ħ�&?ɐ�/�d4Ab���Y�!y�~�\x00�\x16�:\x7F\x01\x00\x00' }
i can't use JSON in application,even after using express.json in index.ts file
require("dotenv").config();
import express, { Request, Response, Express } from "express";
import { createProxyMiddleware } from "http-proxy-middleware";
import sfHelper from "./v1/helper/sfhelper";
import getconfigdata from "./v1/helper/confighelper";
import router from "./router/index";
const bodyParser = require('body-parser');
var cors = require('cors')
const app: Express = express();
app.use("/api", router);
app.use(express.json());
app.use(cors())
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: true
}));
app.listen(process.env.PORT, async () => {
console.log("App Runnig in 4000");
});
express.jsonandbodyparser.json, they do the same thing. Whichever you use, it should be above theapp.use("/api", router). If that doesn't fix things, can you log out the content-type of the request to see if it's actually JSON?