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 :: js camel case to snake case 
Javascript :: this.$router.push nuxt 
Javascript :: define keyframes with javascript 
Javascript :: nodered - run nodered on docker 
Javascript :: remove whitespace javascript 
Javascript :: jquery check if iframe is loaded 
Javascript :: react native get current time 
Javascript :: js go back 
Javascript :: js get the week monday to friday date 
Javascript :: javascript word start with 
Javascript :: jquery change href value 
Javascript :: motify react native 
Javascript :: remove special characters javascript 
Javascript :: set playback speed js 
Javascript :: show div js 
Javascript :: jsx if block 
Javascript :: how select start from id in jquery 
Javascript :: how to truncate string in javascript 
Javascript :: check if the data can be parsed javascript 
Javascript :: detect touch react 
Javascript :: js sort string array 
Javascript :: refresh a page in jquery 
Javascript :: tailwind confirm 
Javascript :: redirect script javascript 
Javascript :: javascript array distinct 
Javascript :: material ui select helper text 
Javascript :: console log state object redux 
Javascript :: how to pass props in gatsby link using styledcomponent 
Javascript :: flutter text with icon 
Javascript :: jquery if element is clicked 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =