My Front-end Code:-
const [stocks, setStocks] = useState([
{
"name": "TSLA"
},
{
"name": "AAPL"
},
{
"name": "AMZN"
}
])
useEffect(() => {
fetch('http://localhost:2701/' , {
method: "POST",
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify(stocks)
})
.then((result) => {
console.log(result)
})
.then((info) => { console.log(info); })
})
My Back-end Code:-
router.post('/', async (req, res) => {
var data = req.body.data;
console.log("Data:-", data)
})
I want to send values from reactjs to nodejs server, if possible can anyone suggest using axios