首页 > 解决方案 > 在 Contentful SDK 中选择 Operator

问题描述

如何在 Javascript SDK 中使用 Contentful Select Operator 来仅选择属性:字段?

文档中的 GET 请求如下所示

GET https://cdn.contentful.com/spaces/<space-id>/entries/?select=fields

标签: contentful

解决方案


const contentful = require('contentful')

const client = contentful.createClient({
  space: '<space_id>',
  accessToken: '<content_delivery_api_key>'
})

client.getEntries({
  content_type: '<content_type_id>',
  select: 'sys.id,fields.<field_name>'
})
.then((response) => console.log(response.items))
.catch(console.error)

推荐阅读