Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I pass this data i get from axios to the backend which uses node.js (react & node.js)

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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})
})
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading