Answer the question
In order to leave comments, you need to log in
Why does fetch result in Object and not return result?
Why is it that when I try to display the result data
, it is displayed [object Promise]
, and not the text from json
?
And how to get here res.name
?
var data = fetch("ajax.json").then(function(res){
return res.json();
}).then(function(res) {
return res.name;
}).catch();
document.write(data);
Answer the question
In order to leave comments, you need to log in
This is where you call the function with no arguments:
function minusGoods(){
// ......
showCart();
}
function showCart(data) {
var pack = JSON.parse(data);
JSON.parse(undefined)
Look with console.log(data); (put before JSON.parse ) what comes from the handler file, I think you will notice that there is not only json , but "something else". Then go to the handler file and see what sends this "something else". Good luck
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question