https://github.com/bigcommerce/form-poster-js
Post HTML form programmatically
https://github.com/bigcommerce/form-poster-js
form javascript
Last synced: about 1 year ago
JSON representation
Post HTML form programmatically
- Host: GitHub
- URL: https://github.com/bigcommerce/form-poster-js
- Owner: bigcommerce
- License: mit
- Created: 2017-04-02T23:43:29.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-02-26T10:01:00.000Z (over 2 years ago)
- Last Synced: 2024-04-30T02:43:20.388Z (about 2 years ago)
- Topics: form, javascript
- Language: TypeScript
- Homepage:
- Size: 520 KB
- Stars: 5
- Watchers: 60
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# form-poster
[](https://travis-ci.com/bigcommerce/form-poster-js)
This is a JavaScript library for making a POST request as if you are submitting a HTML form. The request will have `application/x-www-form-urlencoded` content-type header. This is useful in situations where you want the same behaviour as submitting a HTML form without actually having the form in DOM.
## Usage
You can install this package using npm or yarn. Below is an example of how to use it.
```js
import { createFormPoster } from 'form-poster';
const formPoster = createFormPoster();
const url = '/url/123';
const data = { field_1: 'foo', field_2: 'bar' };
formPoster.postForm(url, data, () => {
console.log('done');
});
```
## Development
To install dependencies:
```sh
npm install
```
To transpile source code:
```sh
npm run build
```
To bump and tag a release:
```sh
npm run release
```