# Fetch post form data using API

**URL:** <https://forum.wixstudio.com/t/fetch-post-form-data-using-api/30256>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [July 2, 2020, 11:09pm UTC](https://forum.wixstudio.com/t/fetch-post-form-data-using-api/30256 "2020-07-02T23:09:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jscholes](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@jscholes](https://forum.wixstudio.com/u/jscholes)\
**Post date:** [July 2, 2020, 11:09pm UTC](https://forum.wixstudio.com/t/fetch-post-form-data-using-api/30256/1 "2020-07-02T23:09:39Z")

</div>

I am trying to set up my website so that when a customer fills out a form, it sends their submission via API to another source I have. I am having a hard time getting the post api set up properly. I have the form-data module installed. I think I have the back end set up properly, but I’m not sure how to get it working with the front end and actually send the info I need.

Front end code:

import {sendQuote} from ‘backend/test.jsw’ ;

export function button8\_click(event) {  
sendQuote (  
$w( ‘#input4’ ).value,  
$w( ‘#input3’ ).value,  
$w( ‘#input2’ ).value,  
$w( ‘#input1’ ).value)  
.then( function () {  
console.log( “Form information was sent” );  
}  
);  
}

Back end code:

import {fetch} from ‘wix-fetch’ ;  
import FormData from ‘form-data’ ;

function createBody(name, phone, email, state) {  
const form = **new** FormData();

form.append( ‘name’ , name);  
form.append( ‘phone’ , phone);  
form.append( ‘email’ , email);  
form.append( ‘state’ , state);

**return** form  
}

export function sendQuote(name, phone, email, state) {  
**return** fetch( “[https://myurl](https://myurl)” , {  
“method” : “post” ,  
“headers” : {  
“Content-Type” : “application/x-www-form-urlencoded”  
},  
“body” : createBody(name, phone, email, state)  
}).then( (httpResponse) =\> {  
if (httpResponse.ok) {  
**return** httpResponse.json();  
} **else** {  
**return** Promise.reject( “Fetch did not succeed” );  
}  
} )  
.then( (json) =\> console.log(json.someKey) )  
. catch (err =\> console.log(err));  
}

---

<div class="post-metadata">

**Author:** ![nagaraj](https://avatars.discourse-cdn.com/v4/letter/n/a9adbd/32.png) [@nagaraj](https://forum.wixstudio.com/u/nagaraj)\
**Post date:** [February 10, 2022, 8:32am UTC](https://forum.wixstudio.com/t/fetch-post-form-data-using-api/30256/2 "2022-02-10T08:32:13Z")

</div>

@jscholes did you get this working, I am trying to send video to my external API, please let me know.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [February 10, 2022, 8:45am UTC](https://forum.wixstudio.com/t/fetch-post-form-data-using-api/30256/3 "2022-02-10T08:45:52Z")

</div>

Please add your own issue into a new post instead of bumping up an old post. Explain what you are trying to do, what works, and what doesn’t. Also, add any code in a code block as stated in the [Forum Guidelines](https://www.wix.com/corvid/forum/community-discussion/forum-policies-and-guidelines) .

This is an old post and is being closed.
