Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hey, so I'm trying to get a list of all my articles that have not been updated for two years so this allows the content to stay fresh.
I have achieved this with the following code.
angular.module("umbraco").controller("ArticleNotifyController", function ($scope, userService, contentResource, entityResource) { let vm = this; let user = userService.getCurrentUser().then(function (user) { vm.UserName = user.name; }); async function getArticles(){ let articles = []; contentResource.getChildren(2427) .then(function(contentArray) { contentArray.items.forEach(child => { contentResource.getChildren(child.id) .then(function(content) { if (content.items != null){ content.items.forEach(article => { let dateNow = new Date(Date.now()) let articleDate = new Date(Date.parse(article.updateDate)); if(articleDate < dateNow.setMonth(dateNow.getMonth() - 24)){ articles.push(article) } }) } }); }); }); return await articles; }; getArticles().then(function(result) { console.log(result) }); });
this returns my results as expected.
But if I try to access one of the objects in the array using: console.log(result[0]);
console.log(result[0]);
I get undefined can someone please tell me what I am doing wrong as I'm not sure how to access this?
Thanks in advance.
Can you try if result.data[0] works?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Getting Content data from the UmbracoAPI (contentResource)
Hey, so I'm trying to get a list of all my articles that have not been updated for two years so this allows the content to stay fresh.
I have achieved this with the following code.
this returns my results as expected.
But if I try to access one of the objects in the array using:
console.log(result[0]);
I get undefined can someone please tell me what I am doing wrong as I'm not sure how to access this?
Thanks in advance.
Can you try if result.data[0] works?
is working on a reply...