Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript fetch post form data

javascript fetch post form data with headers , in reactjs
--------------------------------
let formData = new FormData();
formData.append('data', 'formdata');
formData.append('data', 'formdata');

export const getData = async () => {
    await fetch('----url------', {
        method: 'POST',
        headers: {
            Authorization: 'Basic -------token----------',
        },
        body: formData
    }).then(response => response.json())
        .then(data => {
            console.log(data);
        })
}
Comment

Send Form Data Using Fetch

async function sendFormData()
 {

 const myData = document.getElementById("myData");
const formData = new FormData(myData);

	const obj= Object.fromEntries(formData);

const res = await fetch('/test', {method:'POST', body: JSON.stringify(obj), headers:{'Content-type': 'application/json; charset=UTF-8'}});
const response = await res.json();

console.log(response["a"]);

 }
Comment

Javascript Fetch FormData

fetch(form.action, {method:'post', body: new FormData(form)});
Comment

PREVIOUS NEXT
Code Example
Javascript :: login page link shopify 
Javascript :: touppercase 
Javascript :: redux dev tools 
Javascript :: how to split text into array javascript 
Javascript :: random word js 
Javascript :: regex match line that does not contain string 
Javascript :: javascript validate email 
Javascript :: 3 letter months javascript array 
Javascript :: convert long date to short date javascript 
Javascript :: cdn react 
Javascript :: sum all elements in array javascript 
Javascript :: mongoose find by and delete 
Javascript :: Factorial multiplication in javascript 
Javascript :: array.find is not a function 
Javascript :: fill an array of zeroes in js 
Javascript :: add css class to html in js 
Javascript :: ReferenceError: primordials is not defined 
Javascript :: factorial javascript 
Javascript :: listen back button event listner 
Javascript :: express-ejs-layouts install 
Javascript :: set min date field to current date 
Javascript :: owl carousel get started 
Javascript :: keyboard event js 
Javascript :: document onload 
Javascript :: bcd full form in electronics 
Javascript :: loop through object in array javascript 
Javascript :: remove duplicate object from array javascript 
Javascript :: vue v-on:click 
Javascript :: Loop array backwards in JS 
Javascript :: how to remove middle characters in string javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =