What's the issue ?
Sep 30, 2021
7
Level 7
How can I mapState?
Below I am trying to map State from returning venue but I'm getting a bit confused?!
computed: {
...mapState('venues/venues', {
venue: state => state.venues,
})
},
async asyncData({ params, $axios }) {
const venue = await $axios.get(`/venues/${params.venue}`)
return { venue }
}
in my store, I have:
const state = () => ({
venues: [],
venue: {},
venue_id: 0,
venuename: '',
postcodes: [],
pagination: {
page: 1,
limit: 10,
totalPages: 0
}
})
The result I get from my async api call is:
{ "data": [ { "id": 51166, "fsa_id": 546117, "user_id": null, "email": null, "venuename": "Wrexham Rugby Club", "slug": "wrexham-rugby-club", "venuetype": null, "address": "Wrexham Rugby Club Bryn Estyn Road, Wrexham, Wrexham", "address2": null, "town": "Wrexham Rugby Club Bryn Estyn Road", "county": "Wrexham", "postcode": "LL13 9TY", "postalsearch": null, "telephone": null, "easting": "335808", "northing": "351078", "latitude": "53.053094", "longitude": "-2.959124", "local_authority": "Wrexham", "website": null, "photo": "images/venues/m0w0omdbElv2cnWuXe3UbzZfeOK3Q0OA3tTRSxZD.jpg", "is_live": 1, "created_at": null, "updated_at": "2021-09-22T20:11:18.000000Z" } ], "status": 200, "statusText": "OK", "headers": { "cache-control": "no-cache, private", "content-type": "application/json" }, "config": { "url": "/venues/51166", "method": "get", "headers": { "Accept": "application/json, text/plain, */*" }, "baseURL": "http://jwtapi.test/api", "transformRequest": [ null ], "transformResponse": [ null ], "timeout": 0, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", "maxContentLength": -1, "maxBodyLength": -1, "transitional": { "silentJSONParsing": true, "forcedJSONParsing": true, "clarifyTimeoutError": false } }, "request": {} }
Please or to participate in this conversation.