diff --git a/web/themes/custom/caravane/assets/js/stores/content.js b/web/themes/custom/caravane/assets/js/stores/content.js index e18a960..d645de6 100644 --- a/web/themes/custom/caravane/assets/js/stores/content.js +++ b/web/themes/custom/caravane/assets/js/stores/content.js @@ -58,11 +58,13 @@ export const useContentStore = defineStore('content', { this.etape.title = etape.attributes.title; this.etape.adresse = etape.attributes.field_adresse; this.etape.etape_number = etape.attributes.field_arret_numero; - const vignetteFetch = await this.fetchContent('field_vignette', etape.relationships); - this.etape.vignette = { - url: vignetteFetch.attributes.uri.url, - alt: etape.relationships.field_vignette.data.meta.alt - }; + const vignetteFetch = await this.fetchContent('field_vignette', etape.relationships); + if (vignetteFetch) { + this.etape.vignette = { + url: vignetteFetch.attributes.uri.url, + alt: etape.relationships.field_vignette.data.meta.alt + }; + } this.etape.couleur = etape.attributes.field_couleur; this.etape.dates = { @@ -216,25 +218,22 @@ export const useContentStore = defineStore('content', { this.resetStore(); this.map = map; try { - const response = await REST.get(`/jsonapi/node/static/`); - console.log("CONTENT, response : ", response); - - for (let page of response.data.data) { - - console.log("CONTENT, page.attributes : ", page.attributes); - - if (page.attributes?.drupal_internal__nid == nid) { + const response = await REST.get(`/jsonapi/node/static/`); + for (let page of response.data.data) { + if (page.attributes.drupal_internal__nid == nid) { for (let metatag of page.attributes.metatag) { if (metatag.tag === "link") { this.href = metatag.attributes.href; } } this.page.title = page.attributes.title; - const vignetteFetch = await this.fetchContent('field_vignette', page.relationships); - this.page.vignette = { - url: vignetteFetch.attributes.uri.url, - alt: page.relationships.field_vignette.data.meta.alt - }; + const vignetteFetch = await this.fetchContent('field_vignette', page.relationships); + if (vignetteFetch) { + this.page.vignette = { + url: vignetteFetch.attributes.uri.url, + alt: page.relationships.field_vignette.data.meta.alt + }; + } const partiesFetch = await this.fetchContent('field_parties_static', page.relationships); if (partiesFetch) {