feat: Update to the new SDK

This commit is contained in:
Khaled Garbaya
2018-04-19 15:53:02 +02:00
committed by Khaled Garbaya
parent 1baef21340
commit 8a2b7dc649
33 changed files with 27 additions and 17 deletions

6
app.js
View File

@@ -16,7 +16,7 @@ const breadcrumb = require('./lib/breadcrumb')
const { updateCookie } = require('./lib/cookies')
const settings = require('./lib/settings')
const routes = require('./routes/index')
const { getSpace } = require('./services/contentful')
const { getSpace, getLocales } = require('./services/contentful')
const { catchErrors } = require('./handlers/errorHandlers')
const SETTINGS_NAME = 'theExampleAppSettings'
@@ -97,12 +97,12 @@ app.use(catchErrors(async function (request, response, next) {
// Catch misconfigured space credentials and display settings page
try {
const space = await getSpace()
const locales = await getLocales()
// Update credentials in cookie when space connection is successful
updateCookie(response, SETTINGS_NAME, response.locals.settings)
// Get available locales from space
response.locals.locales = space.locales
response.locals.locales = locales
const defaultLocale = response.locals.locales
.find((locale) => locale.default)