Recently, I've been exploring the fetch API to retrieve some data. After successfully fetching the data and displaying the response using console log, I now face a challenge in utilizing this information. The API provides me with "result", "id", and "total" fields. I am seeking assistance on how I can convert this data into a string array and effectively leverage the insights offered by the API.
I attempted various approaches, including JSON.Parse, but struggled to convert the JSON data into a string array.
Here is the function where I aim to handle the fetched data for further processing:
function addPost(e){
e.preventDefault();
let itemname = document.getElementById('itemname').value;
let body = document.getElementById('body').value;
fetch('https://cors-anywhere.herokuapp.com/https://www.pathofexile.com/api/trade/search/Standard', {
method:'POST',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-type':'application/json'
},
body: JSON.stringify({"query": {"status": {"option": "online"}, "name":itemname, "stats": [{"type": "and", "filters": []}]},"sort": {"price": "asc"}})
})
.then((res) => res.json())
.then((data) => console.log(JSON.stringify(data)));
}