fixup! fix(errors): properly output API error information

This commit is contained in:
Khaled Garbaya
2018-02-08 14:18:51 +01:00
committed by Khaled Garbaya
parent 9ee29c8555
commit fd6de6ef86
2 changed files with 14 additions and 3 deletions

10
app.js
View File

@@ -56,18 +56,22 @@ app.use(catchErrors(async function (request, response, next) {
const qs = querystring.stringify(request.query)
// Creates a query string which adds the current credentials to links
// To other implementations of this app in the about modal
let settingsQs = null
let settingsQuery = {
editorial_features: response.locals.settings.editorialFeatures ? 'enabled' : 'disabled'
}
if (
response.locals.settings.spaceId !== process.env.CONTENTFUL_SPACE_ID ||
response.locals.settings.deliveryToken !== process.env.CONTENTFUL_DELIVERY_TOKEN ||
response.locals.settings.previewToken !== process.env.CONTENTFUL_PREVIEW_TOKEN
) {
settingsQs = querystring.stringify(Object.assign({}, request.query, {
settingsQuery = Object.assign({}, settingsQuery, request.query, {
space_id: response.locals.settings.spaceId,
delivery_token: response.locals.settings.deliveryToken,
preview_token: response.locals.settings.previewToken
}))
})
}
const settingsQs = querystring.stringify(settingsQuery)
response.locals.queryString = qs ? `?${qs}` : ''
response.locals.queryStringSettings = settingsQs ? `?${settingsQs}` : ''
response.locals.query = request.query