jeudi 31 décembre 2020

cant use information array of json file [duplicate]

i've problem, idk why but i can't use my json file for my website...

if i try call the json, it's good but i can't use information... if you have solution, tell me pls T-T

i've test all but nothing work...

entity = fetch("./entity/entity.json")
  .then(response =>{return response.json()})

console.log(entity) /*output: 
                    Promise {<pending>}
                    __proto__: Promise
                    [[PromiseState]]: "fulfilled"
                    [[PromiseResult]]: Array(3)
                        0: {id: "1", title: "inventory 1", description: "l'objet 1 de l'inventaire", price: 50, img: false}
                        1: {id: "2", title: "inventory 2", description: "l'objet 2 de l'inventaire", price: 25, img: false}
                        2: {id: "3", title: "inventory 3", description: "l'objet 3 de l'inventaire", price: 15, img: false}
length: 3
__proto__: Array(0)*/ 


console.log(entity[0]) //output : undefined

tks.




Aucun commentaire:

Enregistrer un commentaire