Noblox: Having issues reading group wall posts with getWall

I am trying to read the first page of my group wall using Noblox in Javascript.

noblox.getWall(2778070, 1).then(function(data){
            var posts = data.posts
            for(var i = 0; i<posts.length; i++){
                var msg = posts[i]
                console.log(msg.author.name + " said: " + msg.content)
            }
        })

The expected output would be for each wall post on page 1:
[username]: [wall post message]

but instead I am receiving an error:

Unhandled rejection TypeError: Cannot read property 'length' of undefined

Disclaimer: I am the maintainer of noblox.js.


Because a number of endpoints were changed recently, a lot of noblox.js functions were updated. This includes getWall(). The GetWall now returns an object formatted like:

{
  previousPageCursor: null,
  nextPageCursor: null,
  data: [
    {
      id: 2002012462,
      poster: {
        userId: 55549140,
        username: 'Qxest',
        buildersClubMembershipType: 'None'
      },
      body: 'PIZZA',
      created: '2019-12-19T18:46:47.27Z',
      updated: '2019-12-19T18:46:47.27Z'
    }
  ]
}

and can be called as follows:

// sortOrder can only be 'Asc' or 'Desc' & limit can only be 10, 25, 50, or 100
noblox.getWall(GroupID, sortOrder, limit, cursor) 

I’m in the process of turning functions like these into readable streams to make it easier. So in the end, what you should be doing is something along the lines of:

noblox.getWall(2778070, 1).then(function(res){
  const posts = res.data
  for(var i = 0; i < posts.length; i++){
      var msg = posts[i]
      console.log(msg.poster.username + " said: " + msg.body)
  }
})
1 Like

Thank you, much appreciated.

Just curious but do you happen to know if the documentation for the updated functions will be updated (for example: Group Functions · noblox/noblox.js Wiki · GitHub)?

The documentation on the wiki pages for noblox.js is incredibly outdated. I’m currently in the process of writing documentation on the gh-pages branch which is shown on https://noblox.js.org. I eventually plan on fading out the wiki as a whole and shifting all documentation here. In the meanwhile you may need to look at method’s arguments in their source files near the top. Sorry for the inconvenience.

2 Likes

Thank you for that link as well!

Thank you for maintaining noblox.js and helping me out.

1 Like

Hi, sorry to bother you but I was just curious if deleteWallPost also got updated? Whenever I comment this code out, the program works but otherwise it fails:

noblox.deleteWallPost(2778070, wallPostId)