Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react fetch request with content type x-www-form-urlencoded

var details = {
    'userName': 'test@gmail.com',
    'password': 'Password!',
    'grant_type': 'password'
};

var formBody = [];
for (var property in details) {
  var encodedKey = encodeURIComponent(property);
  var encodedValue = encodeURIComponent(details[property]);
  formBody.push(encodedKey + "=" + encodedValue);
}
formBody = formBody.join("&");

fetch('https://example.com/login', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
  },
  body: formBody
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: package.json merger 
Javascript :: object declaration in javascript 
Javascript :: Which condition will print hello? var a=2; var b=3; if(a___?___b){console.log(“Hello”);} 
Javascript :: javascript find area of triangle 
Javascript :: react-intersection-observer 
Javascript :: detect javascript disabled 
Javascript :: vue js qr code scanner 
Javascript :: js modulo not working 
Javascript :: nodejs ERR_CONNECTION_REFUSED 
Javascript :: save byte as json string javascript 
Javascript :: use obj property inside itself 
Javascript :: how to prevent render in react 
Javascript :: iteration through json with key value pairs 
Javascript :: jquery script cdn stackoverflow 
Javascript :: cannot read property of undefined reading create material ui 
Javascript :: Image preload React 
Javascript :: axios post data vue js 
Javascript :: ~~ in javascript 
Javascript :: javascript string insensitive compare 
Javascript :: jquery connection reset 
Javascript :: javascript Display Time Every 3 Second 
Javascript :: clear inteval 
Javascript :: react proxy error: could not proxy request from localhost:3000 to http localhost:5000 econnreset 
Javascript :: tilt js vue 
Javascript :: angular router navigate inside setTimeout 
Javascript :: what is == in js 
Javascript :: get file extension of path extendscript 
Javascript :: js check if object key exists 
Javascript :: create express app 
Javascript :: javascript this Inside Function with Strict Mode 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =