prismicio / javascript-kit

Development kit for the Javascript language
https://developers.prismic.io
106 stars 69 forks source link

ExpressJS + Promises #123

Closed azappa closed 8 years ago

azappa commented 8 years ago

I switch to async module to native Promises using babeljs. I write a simple function

const getPrismicApi = async () => { return Prismic.api(configuration.apiEndpoint); }

and I call it in my routes like

const api = await getPrismicApi();
const service = await api.query(`[[:d = at(document.type, "services")][:d = at(my.services.uid, "${_slug}")]]`);

Without this (old fashioned?) line

const p = prismic.withContext(req, res);
p.query(...);

from my templates I cannot access anymore to Prismic methods like doc.getText(field)...

How can set back this funcionality??

Thank you.

azappa commented 8 years ago

Nevermind, I got solution, forgot to pass req and ctx to templates :)