# Accessing custom object in Serverless function

**URL:** <https://community.hubspot.com/t/accessing-custom-object-in-serverless-function/55388>\
**Category:** CMS Development\
**Created:** [April 21, 2022, 9:56am UTC](https://community.hubspot.com/t/accessing-custom-object-in-serverless-function/55388 "2022-04-21T09:56:24Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![SJaeger](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sjaeger/32/2401_2.png) [@SJaeger](https://community.hubspot.com/u/SJaeger)\
**Post date:** [April 25, 2022, 9:47am UTC](https://community.hubspot.com/t/accessing-custom-object-in-serverless-function/55388/5 "2022-04-25T09:47:34Z")

</div>

hey,

why u make it not easy testing/debugging with local nodemon? so u find faster the errors in serverless functions.

create a local index.js file called index.js:

```lia-code-sample
const hubspot = require("@hubspot/api-client");
const API_KEY = 'xxx' // portal api key for testing
const hubspotClient = new hubspot.Client({ apiKey: API_KEY });
const headers = {
 "Content-Type": "application/json"
}

const BASE_URL = 'https://api.sandbox.smartrecruiters.com'

function sendResponse (message) {
 console.log(message)
}

async function serverless (params = {}) {
 const response = await hubspotClient.crm.objects.basicApi.getById("mycustomobject", id, ["myproperty"])
 return response

 sendResponse({
 response,
 statusCode: 200
 });
}

serverless({})

```

now on your local machine where the index.js is localed type: “npm i nodemon @hubspot/api-client”

after nodemon is installed u can type “nodemon index.js”. later u can copy/past this script to your functions folder easily

now u see a detailed error messages from hubspot client.

i think your current code have some errors in initialize process of the hubspot client.

update: with my example i have to update current hubspot client, because i have the old v2 not current v3

---

_[View the full topic](https://community.hubspot.com/t/accessing-custom-object-in-serverless-function/55388)._
