hubpost
TypeScript icon, indicating that this package has built-in type declarations

0.3.2 • Public • Published

hubpost

A little util to submit form data to HubSpot using their forms API.

import { hubpost } from 'hubpost'

const portalId = '123123123'
const formId = '123123-123123-123123-123123'

try {
  await hubpost(portalId, formId, {
    first: 'Megan',
    last: 'Rapinoe'
  })
} catch (e) {
  console.log(e) // => { status, message, correlationId, errors[] }
}

When passing in your form fields, you can optionally structure them as objects in order to specify custom objectTypeId values. They will otherwise default to "contact" type 0-1.

await hubpost(portalId, formId, {
  name: 'Megan Rapinoe',
  position: {
    objectTypeId: '0-1234',
    value: 'Captain'
  }
})

This library also exports HubSpot's default objectTypeId values:

import { objectTypeIds } from 'hubpost'

assert.deepEqual(objectTypeIds, {
  contact: '0-1',
  company: '0-2',
  deal: '0-3',
  ticket: '0-5',
})

License

MIT License © Eric Bailey

Readme

Keywords

Package Sidebar

Install

npm i hubpost

Weekly Downloads

47

Version

0.3.2

License

MIT

Unpacked Size

20.1 kB

Total Files

8

Last publish

Collaborators

  • estrattonbailey