Contentful logo

Contentful Community

Do we need to create a new client for each request?

Hi,
I am currently trying to integrate contentful javascript sdk to a express.js app, but i am not sure how to proceed.

Do you have any advices?

Thank

Hi @olivier.cperrier,

You only need to declare your client once, and then use it to structure whichever queries you may find necessary, as:

const contentful = require("contentful");
const client = contentful.createClient({
  space: "developer_bookshelf",
  accessToken: "preview_0b7f6x59a0",
  host: "preview.contentful.com"
});
client.getEntry(id);
client.getEntry(id2);