Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

post request javascript

const createPostRequest = async () => {
	try{
		const { data } = await axios.post(url, body_data, {
		   headers: {
	    	 'Authorization': `Basic ${token}`
		   },
		})
    
	    console.log(data)
	} catch (error) {
		console.log(error)
	}
}

createPostRequest();
Comment

post requests javascript

xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
xhr.send(someStuff);
Comment

javascript post request

const url = "http://example.com";
fetch(url, {
    method : "POST",
    body: new FormData(document.getElementById("inputform")),
    // -- or --
    // body : JSON.stringify({
        // user : document.getElementById('user').value,
        // ...
    // })
}).then(
    response => response.text() // .json(), etc.
    // same as function(response) {return response.text();}
).then(
    html => console.log(html)
);
 Run code snippet
Comment

PREVIOUS NEXT
Code Example
Javascript :: nodejs: express: package for Router 
Javascript :: js quote 
Javascript :: ternary javascript 
Javascript :: default value of functin atribute 
Javascript :: javascript for...in loop 
Javascript :: modules.exports javascript 
Javascript :: reverse an array 
Javascript :: create text node in javascript 
Javascript :: javascript best online game engine 
Javascript :: crypto random string javascript 
Javascript :: js concate map 
Javascript :: javascript dict 
Javascript :: javascript start 
Javascript :: how to get data from multiple tables mongoose 
Javascript :: javascript developer 
Javascript :: javascript strings 
Javascript :: conver all array to object 
Javascript :: how to add multiple objects into array in javascript 
Javascript :: js repeat 
Javascript :: Search by text score in mongodb 
Javascript :: how to check if an element already exists in an array in javascript 
Javascript :: rest parameter 
Javascript :: last value of array 
Javascript :: validate decimal number with 6 decimal digits javascript 
Javascript :: javascript null 
Javascript :: express framework 
Javascript :: loadsh debounce 
Javascript :: Texto unitário no node js 
Javascript :: mock js random 
Javascript :: cuantos docentes hay en mexico 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =