Answer the question
In order to leave comments, you need to log in
How to parse data from json?
Hello. I have a db in firebase , here it is - .
and my get request is
function json(response) {
return response.json();
}
function saveData(response) {
const data = response;
console.log(data);
}
fetch(`${fireURL}/.json`, {
method: 'GET',
})
.then(json)
.then(saveData);
Answer the question
In order to leave comments, you need to log in
Relevant function:
https://developer.mozilla.org/ru/docs/Web/JavaScri...
This is the received json, in the form of a JS object.
Run through the object and get the data you need:
function saveData(response) {
const data = response;
console.log(data);
for( var prop in data) {
console.log(data[prop], data[prop]['descrName']); //и т.д.
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question