Axios get call receiving the right information but it comes back as a string of the XML data. I need a JSON object.
I am grabbing all the tables on the page then I filter through them and then I want to make a REST call that will only give me the Choice fields. The variable current list name gets the guid and that is later concat'd for the url.
var currentListName = table.getAttribute("id").substring(1, 37);
var root = ctx.HttpRoot;
var listName = "SP.Data." + table.summary + "ListItem";
var data = {
__metadata: { type: listName },
};
var url =
root +
"/_api/web/lists('" +
currentListName +
`')/fields?$filter=TypeDisplayName eq 'Choice'`;
var configureAxios = {
headers: {
Accept: "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
credentials: true,
"X-RequestDigest": document.getElementById("__REQUESTDIGEST").value,
},
};
axios
.get(url, { data: JSON.stringify(data) }, configureAxios)
.then(function (res) {
console.log("response:", res);
})
.catch(function (e) {
console.log("error:", e);
});
});
I get the response.data being a string of the XML data. I want to be JSON so I can access the values within. I'm possibly missing something in the headers?

