Sitemap: Get location modified date if no photo exists
Only for not throwing an error
This commit is contained in:
@@ -47,7 +47,7 @@ export async function get (req, res, next) {
|
||||
baseURL = `http${(req.httpVersion >= 2) ? 's' : ''}://${req.headers.host}`
|
||||
|
||||
// Get locations
|
||||
const locationsReq = await fetch(`${apiEndpoints.rest}/items/locations?fields=slug,country.slug`)
|
||||
const locationsReq = await fetch(`${apiEndpoints.rest}/items/locations?fields=slug,country.slug,modified_on`)
|
||||
const locationsData = await locationsReq.json()
|
||||
const locations = locationsData.data
|
||||
|
||||
@@ -56,7 +56,7 @@ export async function get (req, res, next) {
|
||||
const latestPhotoReq = await fetch(`${apiEndpoints.rest}/items/photos?fields=created_on&limit=1&sort=created_on&filter[location.slug][rlike]=%${location.slug}`)
|
||||
const latestPhotoData = await latestPhotoReq.json()
|
||||
const latestPhoto = latestPhotoData.data[0]
|
||||
location.updated = latestPhoto.created_on
|
||||
location.updated = latestPhoto ? latestPhoto.created_on : location.modified_on
|
||||
return location
|
||||
})
|
||||
await Promise.all(updatedLocations)
|
||||
|
||||
Reference in New Issue
Block a user