Keep getting an undefined promise

Sorry if the question is too simple, but my function keeps getting an empty promise… can you please help me?

const request = require(‘request-promise’);

const hubspot = require(‘@hubspot/api-client’);

const hubspotClient = new hubspot.Client({“accessToken”:“THE ACCESS TOKEN”});

const contactId = ‘51’;

const properties = [“firstname”,

“cedula”,

“email”];

const propertiesWithHistory = [];

const associations = undefined;

const archived = false;

async function f() {

console.log('\*\*bleep\*\*ing work')

try {

    const apiResponse = await hubspotClient.crm.contacts.basicApi.getById(contactId, properties, propertiesWithHistory, associations, archived);

    console.log(JSON.stringify(apiResponse.body, null, 2));

    const a = JSON.stringify(apiResponse.body, null, 2);

    return a;

  } catch (e) {

    e.message === 'HTTP request failed'

      ? console.error(JSON.stringify(e.response, null, 2))

      : console.error(e)

  }

}

const a = f()

console.log(a)

Hi, @Sebasluke :waving_hand: Hey, @JBeatty @taran42 do you have any thoughts on what @Sebasluke can try to troubleshoot their function?

Thank you! — Jaycee

Hi @Sebasluke,

You have a small javascript error here:

const a = f()
console.log(a)

Becuase f is an async function it is returning a promise so you need to await it like so:

const a = await f()
console.log(a)

Except you are in the top level so you actually need to so something like this:

(async ()=>{
 const a = await f()
 console.log(a)
})();

Here I am just defining an async function then imedieatly calling it.

Best,