The following code works as expected. However, I do get a warning:
⚠ Nuxt Warning The command 'nuxt generate' finished but did not exit after 5s ... ... DeprecationWarning: Starting with Nuxt version 3 this will be a fatal error
This is not nice. Getting the error in Netlify
and also when testing on the localhost
.
Here is my nuxt.config:
generate: {
routes() {
// generate portfolio pages
const firebase = require("firebase");
let app;
if (!firebase.apps.length) {
app = firebase.initializeApp(require("./config/firebase"));
} else {
app = firebase.apps[0];
}
const firestore = firebase.firestore();
const mapDocToRoute = doc => {
const data = doc.data();
console.log(data);
return {
route: `/portfoolio/${data.slug}`
// payload: { ...data }
};
};
return new Promise(async (resolve, reject) => {
try {
const portfolioQuery = await firestore.collection("portfolio").get();
const docRoutes = [];
portfolioQuery.forEach(doc => {
docRoutes.push(mapDocToRoute(doc));
});
await app.delete();
app = null;
resolve(docRoutes);
} catch (e) {
// reject(e);
resolve([]);
}
});
}
}
Help is appreciated.