I am trying to create a Axios request where i will post json data. The format of the data will be
{"qBody":"aaa","qAnswer":"bbb","qOptions":[],"qType":"GAP","qClass":6,"qSubject":1,"qChapter":1,"qCreatorid":1,"qCreatorrole":"admin"}
But it is posting as
{"data":{"qBody":"aaa","qAnswer":"bbb","qOptions":[],"qType":"GAP","qClass":6,"qSubject":1,"qChapter":1,"qCreatorid":1,"qCreatorrole":"admin"}}
Here is my code snippet:
var data = {
"qBody" : question,
"qAnswer" : trueFalseAnswer,
"qOptions" : qOptions,
"qType" : questionCategory,
"qClass" : className,
"qSubject" : subjectName,
"qChapter" : chapterName,
"qCreatorid" : qCreatorid,
"qCreatorrole" : qCreatorrole
};
const newData = JSON.stringify(data)
this.$axios.post("http://128.199.192.87:8081/api/v1/questions/add",{
newData
},{
'Content-Type': "application/json"
}).then((response)=>{
console.log(response)
})
How can I make the format correct? Thanks in advance