3

I am trying to list all of the slide object id's in a given presentation. However, res.data.slides.objectId always come back as undefined. Code:

slides.presentations.get({
    presentationId: id,
}, (err, res) => {
    if (err) return error(err);
    length = res.data.slides.length;
    for (a = 0; a <= length; a++){
        let ids = res.data.slides.objectId[a];
        console.log(ids);
        slideObjectIds.push(ids);
        console.log(slideObjectIds);
    }
});

I've tried using JSON.parse(res.data.slides.objectId), but this stops at u, it will probably be undefined. I know it is res.data.slides.objectId because I starting by logging (console.log)res, It was under data, then I logged res.data, and so forth, and found that res.data.slides worked, but res.data.slides.objectId did not work.

Here is the response page.

Thanks for your help!

Arkin Solomon
  • 592
  • 1
  • 5
  • 23

1 Answers1

1

My mistake, res is an object NOT an array, the way I was trying to reference this was by addressing the index. I was able to fix this by using this code:

res.data.slides.forEach((file) => {slideObjectIds.push(file.objectId)});

It pushes the object is to the array slideObjectIds.

Arkin Solomon
  • 592
  • 1
  • 5
  • 23