Rework API calls and each loops
This commit is contained in:
@@ -4,7 +4,14 @@
|
||||
// Preload data
|
||||
export async function preload (page, session) {
|
||||
// Load photos
|
||||
const req = await this.fetch(`${apiEndpoints.rest}/items/photos?fields=id,name,slug,date,image.*,location.*,location.country.*,created_on,modified_on&filter[location.slug][rlike]=%${page.params.place}%&limit=-1&sort=-created_on,name`)
|
||||
const fields = [
|
||||
'id', 'name', 'slug', 'date', 'image.*',
|
||||
'location.id', 'location.name', 'location.region', 'location.country.name',
|
||||
'created_on', 'modified_on'
|
||||
]
|
||||
const sort = ['-created_on', 'name']
|
||||
const limit = -1
|
||||
const req = await this.fetch(`${apiEndpoints.rest}/items/photos?fields=${fields.join()}&filter[location.slug][rlike]=%${page.params.place}%&limit=${limit}&sort=${sort.join()}`)
|
||||
const photos = await req.json()
|
||||
if (req.ok) {
|
||||
return { photos: photos.data }
|
||||
|
||||
Reference in New Issue
Block a user