I have this javascript function that gets called when the search button is pressed. it fetches json from a Flask server. Then its supposed to parse it with JSON.parse(data)
function search(){
var searchTerm = document.getElementById("songname").value
if(searchTerm === "" == false){
fetch(`/searchq=${searchTerm}`, {
method: "GET"
}).then((response) => {
return response.json()
}).then(function (data) {
result = JSON.parse(data)
//Doesnt work
for (var i in result) {
console.log(result[i], i)
}
})
}
}
but when i loop over the result, it just outputs every single character instead of every key, value pair.