How can I get blocks of a structured text field along with the value using content management API?
You can use the nested
attribute to fetch records with their block records ( List all records - Record - Content Management API ).
You can use nested
even with a single record fetch, but our documentation is outdated (thanks for this! Iโll update it)
For example:
const { SiteClient } = require("datocms-client");
const client = new SiteClient("<TOKEN>");
async function getRecord() {
const record = await client.items.find("<RECORD-ID>", {
nested: true,
});
console.log(JSON.stringify(record));
}
getRecord();
Thanks for your answer. Can we have something like graphql api - blocks
and value
are 2 separate fields which can be rendered by react-datocms library?
also links
along with blocks as is in graphql api
unfortunately not, the React component is made to work with the GraphQL API, which is the preferred way to read content.
same here, whatโs your use case? Why canโt you use the GraphQL API directly?
we wanted to cache/manipulate data on webhook calls.
sorry, I donโt understand what you are trying to do here. Are you trying to write back to us something? If so why are you concerned with the React component?
Sorry about the misunderstanding. Please ignore this.