# React App Form Creation

**URL:** <https://community.hubspot.com/t/react-app-form-creation/12590>\
**Category:** APIs & Integrations\
**Tags:** forms\
**Created:** [December 14, 2018, 9:39pm UTC](https://community.hubspot.com/t/react-app-form-creation/12590 "2018-12-14T21:39:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [December 14, 2018, 9:39pm UTC](https://community.hubspot.com/t/react-app-form-creation/12590/1 "2018-12-14T21:39:09Z")

</div>

Hi folks,  
I’m on a free hubspot account and I’m trying to create and use the Form API.

I’ve created the following method, which is bring called right after I collect the requisite form information from a JSX object.

When I click submit, and this method is fired, I do not see anything in Hubspot.  
The server responses with 200s, no failures as far as I can tell.

I added the tracking cookie into my render method for page I’m creating, but I’m not sure if that’s required - is there a way to test whether it’s working?

Thanks and looking forward to hearing from this community on the best way to fix this system, thanks.

Here is my method:

handleSubmit = () =\> {  
preventDefault();  
var https = require(‘https’);  
var querystring = require(‘querystring’);  
// build the data object  
var postData = querystring.stringify({  
‘email’: this.state.email,  
‘firstname’: this.state.firstName,  
‘lastname’: this.state.lastName,  
‘company’: this.state.company,  
‘hs\_context’: JSON.stringify({  
“hutk”: req.cookies.hubspotutk,  
“ipAddress”: req.headers[‘x-forwarded-for’] || req.connection.remoteAddress,  
“pageUrl”: “[https://www.getherd.app/about](https://www.getherd.app/about)”,  
“pageName”: “About”,  
“emailShouldResubscribe”: false  
})  
});  
console.log(postData);

```auto
// set the post options, changing out the HUB ID and FORM GUID variables.
var options = {
 hostname: 'forms.hubspot.com',
 path: '/uploads/form/v2/4900235/46a2aedd-6cd5-4763-9993-fa91f115f5f7',
 method: 'POST',
 headers: {
 'Content-Type': 'application/x-www-form-urlencoded',
 'Content-Length': postData.length
 }
}

// set up the request
var request = https.request(options, function(response){
 console.log("Status: " + response.statusCode);
 console.log("Headers: " + JSON.stringify(response.headers));
 response.setEncoding('utf8');
 response.on('data', function(chunk){
 console.log('Body: ' + chunk)
 });
});

request.on('error', function(e){
 console.log("Problem with request " + e.message)
 this.setState({
 message: e.message
 })
});

// post the data
request.write(postData);
console.log(request);
request.end();

```

}

---

<div class="post-metadata">

**Author:** ![IsaacTakushi](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/isaactakushi/32/70387_2.png) [@IsaacTakushi](https://community.hubspot.com/u/IsaacTakushi)\
**Post date:** [December 17, 2018, 4:13pm UTC](https://community.hubspot.com/t/react-app-form-creation/12590/2 "2018-12-17T16:13:10Z")

</div>

Welcome, [@getherd](https://community.hubspot.com/u/getherd)!

To confirm, are you trying to `POST` to this form client-side? If so, the [v2 Forms API endpoint](https://developers.hubspot.com/docs/methods/forms/submit_form) does _not_ support [CORS / AJAX requests](https://developers.hubspot.com/docs/faq/do-hubspot-apis-support-ajax-request), but the [v3 Forms API endpoint](https://developers.hubspot.com/docs/methods/forms/submit_form_v3) does.

It looks like you may have already discovered this, as [this submission](https://app.hubspot.com/forms/4900235/46a2aedd-6cd5-4763-9993-fa91f115f5f7/submissions/839a35e0-9a3b-46ca-8468-ca0fae48fbed) came through successfully yesterday using the AJAX endpoint.

---

<div class="post-metadata">

**Author:** ![znwhite](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/znwhite/32/91658_2.png) [@znwhite](https://community.hubspot.com/u/znwhite)\
**Post date:** [July 16, 2021, 7:10pm UTC](https://community.hubspot.com/t/react-app-form-creation/12590/3 "2021-07-16T19:10:14Z")

</div>

If you’re open to using axios and Hubspot’s v3 Forms API, I wrote up a solution here:

[https://www.devtwins.com/blog/hubspot-forms-react-submit-form-using-hubspot-api](https://www.devtwins.com/blog/hubspot-forms-react-submit-form-using-hubspot-api)
