0

I am trying to send a Json Data received from Formik. Data should look like this, and does look like this when console.log on Before sending:

{   config: {
       "dev_token": "merrr",
       "scs_date": "2020-02-05",
       "user_roll": "homie"
       }
}

However when I console log my req.body in Nodejs, I get this:

{
  config: '{\n' +
    '  "dev_token": "merrr",\n' +
    '  "scs_date": "2020-02-05",\n' +
    '  "user_roll": "homie"\n' +
    '}'
}

Why do I get the data without \n' attached? Any idea how to fix this? The Axios request I made looks like this:

 Axios.post("http://localhost:8080/pd/sources/configure/"+this.state.ModalisName,{ "config" :config })
                                     .then(result => {
                                         console.log("PUT result", result)
                                     })
                                     .catch(err =>{
                                          console.log( "PUT err", err);
                                      })

1 Answer 1

1

Was caused by JSON.stringify() which I passed in before send the data over. Removed it and everything works well.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.