Skip to content

Instantly share code, notes, and snippets.

@andrewmartin
Created March 5, 2018 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewmartin/db8fed065a1ed5d6276f5f444c1d1afa to your computer and use it in GitHub Desktop.
Save andrewmartin/db8fed065a1ed5d6276f5f444c1d1afa to your computer and use it in GitHub Desktop.
contentful-api-endpoint-node
const contentful = require('contentful');
const client = contentful.createClient({
space: '<space_id>',
accessToken: '<access_token>',
});
export default (req, res) => {
return client.getEntry({
content_type: 'page',
'fields.title': req.params.title,
})
.then((entry) => {
return res.json(entry);
})
.catch(error => {
return res
.status(400)
.json({
error: error.response.data,
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment