JSON.stringify with axios post

Viewed 27

I have a JSON payload which I send to the server using axios POST. The key parameter in the payload is a string retrieved from JSON.stringify. The backend alse expects a string. If I output the key it looks ok (pic1). When adding the key in the payload backslashes are added(pic2). DB value looks ok again without backslashes(pic3), but retrieving the raw value I get the backslashes again (pic4). What is going on here?

This is how I set up the payload:

let puked = JSON.stringify(keys.rsaPuk);
console.log(puked);

var accountRequest =  {
    "pukedKey":  {key: puked}
}


axios.post(Vue.prototype.$backendUrl + "/v1/accounts", {
    accountRequest : accountRequest            
})

Pic1 [Pic22 Pic3 Pic4

0 Answers
Related