# getPage is returning undefined

**URL:** <https://community.hubspot.com/t/getpage-is-returning-undefined/69034>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [November 10, 2022, 5:02pm UTC](https://community.hubspot.com/t/getpage-is-returning-undefined/69034 "2022-11-10T17:02:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hankscrpio](https://avatars.discourse-cdn.com/v4/letter/h/9fc348/32.png) [@hankscrpio](https://community.hubspot.com/u/hankscrpio)\
**Post date:** [November 10, 2022, 5:02pm UTC](https://community.hubspot.com/t/getpage-is-returning-undefined/69034/1 "2022-11-10T17:02:04Z")

</div>

Hello all,

I am going through the private app tutorial and attempting to simply query for a list of Contacts via the hubspotClient API, however, when I do so, I am get “undefined” in the response body.

I am using the access token given to me by HubSpot and when I use the same token with a curl command, I get th expected results.

`const ACCESS_TOKEN = process.env.ACCESS_TOKEN;//=============================================================================//// Using Private App Access Token to configure HubSpot API Client instance ////=============================================================================//const hubspotClient = new hubspot.Client({ accessToken: ACCESS_TOKEN });//==================================================//// Using an API Client to Query the HubSpot API ////==================================================//const getContacts = async () => { const limit = 10; const after = undefined; const properties = undefined; const propertiesWithHistory = undefined; const associations = undefined; const archived = false; try { const apiResponse = await hubspotClient.crm.contacts.basicApi.getPage(limit, after, properties, propertiesWithHistory, associations, archived); console.log(JSON.stringify(apiResponse.body, null, 2)); } catch (e) { e.message === 'HTTP request failed' ? console.error(JSON.stringify(e.response, null, 2)) : console.error(e) }} `

apiResponse.body is “undefined”

Any help would be greatly appreciated! Thanks!

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [November 14, 2022, 10:10pm UTC](https://community.hubspot.com/t/getpage-is-returning-undefined/69034/2 "2022-11-14T22:10:23Z")

</div>

Hey, @hankscrpio 👋 A few questions to help the community better understand. Is this issue occurring when you make a request from the endpoint tab [here](https://developers.hubspot.com/docs/api/crm/contacts)? How about if you use a tool like postman?

I just ran a quick test using a Private App:

Endpoint

`GET /crm/v3/objects/contacts`

Request

```lia-code-sample
const hubspot = require('@hubspot/api-client');

const hubspotClient = new hubspot.Client({"accessToken":"YOUR_ACCESS_TOKEN"});

const limit = 10;
const after = undefined;
const properties = undefined;
const propertiesWithHistory = undefined;
const associations = undefined;
const archived = false;

try {
 const apiResponse = await hubspotClient.crm.contacts.basicApi.getPage(limit, after, properties, propertiesWithHistory, associations, archived);
 console.log(JSON.stringify(apiResponse.body, null, 2));
} catch (e) {
 e.message === 'HTTP request failed'
 ? console.error(JSON.stringify(e.response, null, 2))
 : console.error(e)
}

```

Response

```lia-code-sample
HTTP 200

{
 "results": [
 {
 "id": "1",
 "properties": {
 "createdate": "2022-06-29T17:59:00.693Z",
 "email": "emailmaria@hubspot.com",
 "firstname": "Maria",
 "hs_object_id": "1",
 "lastmodifieddate": "2022-08-11T23:25:03.952Z",
 "lastname": "Johnson (Sample Contact)"
 },
 "createdAt": "2022-06-29T17:59:00.693Z",
 "updatedAt": "2022-08-11T23:25:03.952Z",
 "archived": false
 },
 {
 "id": "51",
 "properties": {
 "createdate": "2022-06-29T17:59:01.172Z",
 "email": "bh@hubspot.com",
 "firstname": "Brian",
 "hs_object_id": "51",
 "lastmodifieddate": "2022-08-02T17:50:32.754Z",
 "lastname": "Halligan (Sample Contact)"
 },
 "createdAt": "2022-06-29T17:59:01.172Z",
 "updatedAt": "2022-08-02T17:50:32.754Z",
 "archived": false
 },
 {
 "id": "101",
 "properties": {
 "createdate": "2022-06-30T04:07:35.653Z",
 "email": "jaycee@example.com",
 "firstname": null,
 "hs_object_id": "101",
 "lastmodifieddate": "2022-08-02T17:50:32.092Z",
 "lastname": null
 },
 "createdAt": "2022-06-30T04:07:35.653Z",
 "updatedAt": "2022-08-02T17:50:32.092Z",
 "archived": false
 },
 {
 "id": "201",
 "properties": {
 "createdate": "2022-06-30T05:20:31.927Z",
 "email": "jaycee222@example.com",
 "firstname": null,
 "hs_object_id": "201",
 "lastmodifieddate": "2022-08-02T17:50:33.777Z",
 "lastname": null
 },
 "createdAt": "2022-06-30T05:20:31.927Z",
 "updatedAt": "2022-08-02T17:50:33.777Z",
 "archived": false
 },
 {
 "id": "251",
 "properties": {
 "createdate": "2022-06-30T05:54:47.865Z",
 "email": "jaycee2224@example.com",
 "firstname": null,
 "hs_object_id": "251",
 "lastmodifieddate": "2022-08-02T17:50:33.588Z",
 "lastname": null
 },
 "createdAt": "2022-06-30T05:54:47.865Z",
 "updatedAt": "2022-08-02T17:50:33.588Z",
 "archived": false
 },
 {
 "id": "301",
 "properties": {
 "createdate": "2022-07-08T04:15:03.373Z",
 "email": "testing@testingmctest.com",
 "firstname": "Jaycee",
 "hs_object_id": "301",
 "lastmodifieddate": "2022-09-20T20:35:49.906Z",
 "lastname": null
 },
 "createdAt": "2022-07-08T04:15:03.373Z",
 "updatedAt": "2022-09-20T20:35:49.906Z",
 "archived": false
 },
 {
 "id": "351",
 "properties": {
 "createdate": "2022-07-15T17:28:54.557Z",
 "email": "testingapis@hubspot.com",
 "firstname": "HubSpot",
 "hs_object_id": "351",
 "lastmodifieddate": "2022-08-02T17:50:32.636Z",
 "lastname": "Test"
 },
 "createdAt": "2022-07-15T17:28:54.557Z",
 "updatedAt": "2022-08-02T17:50:32.636Z",
 "archived": false
 },
 {
 "id": "451",
 "properties": {
 "createdate": "2022-08-03T17:25:46.314Z",
 "email": "pickles@catsrule.xyz",
 "firstname": "Pickles",
 "hs_object_id": "451",
 "lastmodifieddate": "2022-10-17T17:08:36.651Z",
 "lastname": "Lewis"
 },
 "createdAt": "2022-08-03T17:25:46.314Z",
 "updatedAt": "2022-10-17T17:08:36.651Z",
 "archived": false
 },
 {
 "id": "501",
 "properties": {
 "createdate": "2022-08-11T23:25:21.585Z",
 "email": null,
 "firstname": "Fiona",
 "hs_object_id": "501",
 "lastmodifieddate": "2022-10-24T20:09:43.571Z",
 "lastname": "Cat"
 },
 "createdAt": "2022-08-11T23:25:21.585Z",
 "updatedAt": "2022-10-24T20:09:43.571Z",
 "archived": false
 },
 {
 "id": "551",
 "properties": {
 "createdate": "2022-08-11T23:27:36.511Z",
 "email": "pickle@cat.com",
 "firstname": "Pickle",
 "hs_object_id": "551",
 "lastmodifieddate": "2022-10-24T20:09:43.862Z",
 "lastname": "Cat"
 },
 "createdAt": "2022-08-11T23:27:36.511Z",
 "updatedAt": "2022-10-24T20:09:43.862Z",
 "archived": false
 }
 ],
 "paging": {
 "next": {
 "after": "552",
 "link": "https://api.hubapi.com/crm/v3/objects/contacts?hs_static_app=endpoint-reference-ui&hs_static_app_version=1.1342&limit=10&archived=false&after=552"
 }
 }
}

```

Thanks for the additional information! — Jaycee

---

<div class="post-metadata">

**Author:** ![hankscrpio](https://avatars.discourse-cdn.com/v4/letter/h/9fc348/32.png) [@hankscrpio](https://community.hubspot.com/u/hankscrpio)\
**Post date:** [November 14, 2022, 10:23pm UTC](https://community.hubspot.com/t/getpage-is-returning-undefined/69034/3 "2022-11-14T22:23:48Z")

</div>

Thanks for the assist. I think we have it working now.  
I believe the code was accurate but we were accessing the wrong variable in  
the response.  
This can be closed. Thanks!
