Im Grunde habe ich mehrere verschiedene Abrufmethoden ausprobiert habe es mit nein .then() versucht, ich habe die gleiche Methode wie in meinem anderen Projekt mit einem JSON-Array in einer lokalen Datei verwendet und habe wiederholt das gleiche Ergebnis erzielt. Die Funktion führt nicht einmal ein Konsolenprotokoll aus. Kann ich irgendwo einen Fehler gemacht haben?
Bitte sehen Sie sich meinen Code unten an:
HTML:
Code: Select all
Code: Select all
async function sortLocations() {
console.log('1')
let loc1 = await fetch("locations-test.json", {
method: "GET",
headers: {
Accept: "application/json"
}
})
.then(response => response.json())
.then(response => console.log(JSON.stringify(response)));
console.log('2')
\\ ... Code to use the fetched data ...
Code: Select all
[
{...},
{...},
{...},
{
company: "text",
banner: "text",
icon: "text",
locations: [
{
name: "text",
img: "text",
latLong: [num, num],
address: "text",
postcode: "text",
tenants: [
{
company: "text",
banner: "text",
icon: "text"
}
]
}
]
},
{...},
{...}
]