In Contenful I created blog as a content model, where a rich text editor is used as a «data type» for the main blog content. This rich text response is returned as a JSON array of nodes that follows the format of an abstract syntax tree.
In my code I need to add each blog post content as a separate array element.
(see this for response object sample)
for (var a in response) {
//console.log(response[a].fields.content);
const next_content_array = response[a].fields.content.content;
console.log(next_content_array.length);
for (var b in next_content_array) {
//console.log(next_content_array[b].content);
const next_next_content_arrays = next_content_array[b].content;
const text_array_content = [];
const arr = []
for (var c in next_next_content_arrays) {
const value = next_next_content_arrays[c].value;
arr.push(value);
//console.log(c + " " + value);
}
text_array_content.push(arr);
//console.log(arr);
//console.log(text_array_content);
}
}
For two out of three blog posts this works as expected, but for the last one it gets separated into two blog post so I end up with 4 blog posts instead of 3, for my blog post array.
Why is this happening and how can I fix it?