Sending a GET
Request:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = () => {
console.log(`response-text -> ${xhttp.responseText}`);
}
xhttp.open("GET", "http://localhost:3001/get/", true);
xhttp.send("hello world");
Working with ExpressJS :
const express = require('express');
const app = express();
const cors = require('cors');
app.use(cors({origin: '*'}))
app.get('/get/', (req, res) => {
res.send(`Your Request -> ${req.params}`);
})
app.listen(3001);
Debugging in console:
response-text -> Your Request -> [object Object]
Despite trying req.query
and body-parser, the output remains as either [object Object]
or undefined