Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Elliot 1 post 72 karma points
    Jan 30, 2019 @ 10:38

    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.

    angular.module("umbraco").controller("ArticleNotifyController", function ($scope, userService, contentResource, entityResource) {
    let vm = this;
    let user = userService.getCurrentUser().then(function (user) {
        vm.UserName =;
    async function getArticles(){
    let articles = [];
        .then(function(contentArray) {
            contentArray.items.forEach(child => {
                .then(function(content) {
                    if (content.items != null){
                        content.items.forEach(article => {
                            let dateNow = new Date(
                            let articleDate = new Date(Date.parse(article.updateDate));
                            if(articleDate < dateNow.setMonth(dateNow.getMonth() - 24)){
        return await articles;
    getArticles().then(function(result) {

    this returns my results as expected.

    enter image description here

    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.

  • Erik Eelman 79 posts 318 karma points
    Jan 30, 2019 @ 11:47
    Erik Eelman

    Can you try if[0] works?

Please Sign in or register to post replies

Write your reply to: