This is the backend (node.js) route that i want to send the data to.
app.post('/saveDiseaseDetails' , (req , res) => {
//Console.log the data here
})
This is the axios that returns some data and I want to send that data to the backend
axios.post("https://api.plant.id/v2/identify", data)
.then(({ data }) => console.log("SUCCESS", data))}
Basically, what I want is to get the data from the axios request and console.log it in the backend. I am new to react and axios so I am having a little bit trouble
CodePudding user response:
Frontend
const url_to_your_backend //this has to be added accordingly
axios.post("https://api.plant.id/v2/identify", data)
.then(async({ data }) =>{
console.log("SUCCESS", data)
const backend_response=await axios.post(url_to_your_backend,data,{})
console.log("backend response",backend_response)
})
Backend
app.post('/saveDiseaseDetails' , (req , res) => {
//Console.log the data here
console.log(req.body)
res.status(200).json({message:"received data in backend})
})