lhosb
lhosb

Reputation: 1

GroupMe API call returning [Object] instead of actual json

Ok, so I am new to this stuff. I am attempting to make a Bot on GroupMe and need a list of the group's members. Here is my current call. The response looks good except for the member's key.

const rp = require("request-promise");

var options = {
  uri: `https://api.groupme.com/v3/groups/${env.GROUP_ID}`,
  qs: {
    access_token: env.ACCESS_TOKEN,
  },
  headers: {
    "User-Agent": "Request-Promise",
  },
  json: true,
};

rp(options)
  .then(function (group) {
    console.log(group);
  })
  .catch(function (err) {
    // API call failed...
  });

The member portion of the response (there are two members in this group):

members: [ [Object], [Object] ],

And if I change the log to be this: console.log(group.members) I am returned undefined.

I would expect to have the objects of the members.

Here are the docs: https://dev.groupme.com/docs/v3#groups_show

Upvotes: 0

Views: 58

Answers (1)

lhosb
lhosb

Reputation: 1

The answer is I was dumb and didn't see the the response was being returned inside of a larger key/value pair.

Example:

 { response:
   { id: 'xxxxx',
     group_id: 'xxxxx',
     name: 'Test',
     members: [...]
 }

Upvotes: 0

Related Questions