I retrieved data from server with the ajax method but I don't know how to extract this data out of response text to use it somewhere else.
Any suggestions how to do this would be greatly appreciated.
fetch("/path_to_file/data.json").then(response => {
return response.text();
}).then(data => {
if(data) {
var foo = JSON.parse(data);
console.log(data); // {"key1":"value1","key2":"value2"}
retrieveData(foo.key1,foo.key2);
}
});
function...
Code (markup):
from JavaScript https://ift.tt/2uVlEP4
via IFTTT

0 Comments