🏠 back to Observable

Error processing json data retrieved with fetch.

Hi, this is my first attempt to use Observable. I’m stuck with a strange behavior.
I build this notebook to explain it.

Can anyone help please ?

Json() returns a promise. Observable detects and resolves it when it’s a cell returning a promise. In your second example you need ‘then’ or an await (make enclosing function async)

Thanks for anwering, but if you meant this:
not_a_solution = fetch(“https://cors-anywhere.herokuapp.com/http://sdmx.istat.it/SDMXWS/rest/dataflow?format=jsonstructure”).then(function(response) {
return response.json()
}).then(function(d) {
return d.data.dataflows
}).then(function(data) {
return data.map(e => {return {id: e.id, name: e.name.en}})
})
it does not seem to work, either.
If not I did not understand where the “then” or “await” should be put.

example:-

fetch('http://example.com/movies.json')
  .then(response => response.json())
  .then(data => console.log(data));

Sorry the problem was the name was undefined.

The following works:-

does_not_work = fetched_data.map(e => {return {id: e.id, name: e.name ? e.name.en : null}})

Problem row:-

 215: Object {id: "27_945", name: null}

Great !
Thanks a lot :slight_smile: