Skip to content
Advertisement

symfony – key “id” for array with key “0,1,2,3,4,5,6” does not exist

I have an error in my symfony project:

JavaScript

I no longer have an object from 0 to 6 in my database because I had to overwrite the data with make: auth, I believe for security

I have new values but I don’t know what to do to avoid this error.

I try to make the climbing sites of my database appear on my openstreet map. So I loop on the id in javascript, with the leaflet API.

JavaScript

I am getting the error quoted above.

here is the structure of my database here is the structure of my database

Thank you. Cordially.

Advertisement

Answer

Have a look at the documentation for for...in, when you use sites.id it isn’t pointing to anything.

I am assuming that the data is not like you show, and you do have the ID value on the elements. If that is true, and your data looks like on the snippet, you have to update that reference to sites[site].id. Otherwise, edit your answer to show what your data looks like, with the ID on it.

JavaScript

It sounds like you control the server, an improvement could be to update the method to return an array of sites, instead of an object with site names as the keys, as follows:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement