In the case of text().then()
, the string can be retrieved successfully, but when I try to retrieve it with data, the following error appears:
I'd like to loop with the JSON I got and make an id price table...
error messages:
calendar:164 Uncaught (promise) TypeError: response.data is not a function
at masako —164
(anonymous) @masako:164
source code:
var url=$url+"?date="+param(value);
let myFetch=fetch(url);
myFetch.then(function(response){
console.log(response);
response.text().then(function(text){
If there is no // data, text can retrieve it successfully.
// [{"id":25, "price":300}, {"id":27, "price":400},});
response.data().then(function(data){
});
This is helpful.
https://developer.mozilla.org/ja/docs/Web/API/Fetch_API/Using_Fetch
Quote:
fetch('http://example.com/movies.json')
.then(response=>response.json())
.then(data=>console.log(data)));
Therefore, I think it will be as follows.
let myFetch=fetch(url);
myFetch
.then(response=>response.json())
.then(data=>console.log(data)));
© 2024 OneMinuteCode. All rights reserved.