Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/estrattonbailey/hubpost
A little util to submit form data to HubSpot
https://github.com/estrattonbailey/hubpost
ajax form hubspot
Last synced: 3 months ago
JSON representation
A little util to submit form data to HubSpot
- Host: GitHub
- URL: https://github.com/estrattonbailey/hubpost
- Owner: estrattonbailey
- License: mit
- Created: 2022-01-19T23:22:59.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-20T14:18:12.000Z (almost 3 years ago)
- Last Synced: 2024-10-06T03:10:03.251Z (3 months ago)
- Topics: ajax, form, hubspot
- Language: JavaScript
- Homepage:
- Size: 14.6 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# hubpost
A little util to submit form data to HubSpot using their [forms
API](https://legacydocs.hubspot.com/docs/methods/forms/submit_form).```javascript
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`.```javascript
await hubpost(portalId, formId, {
name: 'Megan Rapinoe',
position: {
objectTypeId: '0-1234',
value: 'Captain'
}
})
```This library also exports HubSpot's default `objectTypeId` values:
```javascript
import { objectTypeIds } from 'hubpost'assert.deepEqual(objectTypeIds, {
contact: '0-1',
company: '0-2',
deal: '0-3',
ticket: '0-5',
})
```## License
MIT License © [Eric Bailey](https://estrattonbailey.com)