ImageUpload.js
axios.get('http://localhost:3001/encrypt' , { key : this.state.key}).then(response =>{
console.log(response.data) ;
}).catch(error=>{
console.log(error);
})
app.js
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.get('/encrypt', (req, res) => {
res.header("Access-Control-Allow-Origin", "http://localhost:3000")
res.header("Access-Control-Allow-Headers")
console.log(req.body) // it is returning {}
res.send('hey nodejs')
});
Here, in app.js , req.body is returning an empty object due to which i am unable to access the key value from the object i sent during get request in 'ImageUpload.js' .