Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

fetch with bearer token

fetch('URL_GOES_HERE', { 
   method: 'post', 
   headers: new Headers({
     'Authorization': 'Basic '+btoa('username:password'), 
     'Content-Type': 'application/x-www-form-urlencoded'
   }), 
   body: 'A=1&B=2'
 });
Comment

fetch bearer token

const token = localStorage.getItem('token')

const response = await fetch(apiURL, {
        method: 'POST',
        headers: {
            'Content-type': 'application/json',
            'Authorization': `Bearer ${token}`, // notice the Bearer before your token
        },
        body: JSON.stringify(yourNewData)
    })
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript remoev css class 
Javascript :: remove disable attr jquery 
Javascript :: jquery change selected option to first 
Javascript :: js get url params 
Javascript :: javascript hasownproperty 
Javascript :: remove last two elements array javascript 
Javascript :: pyspark dataframe json string 
Javascript :: electron quit app from renderer 
Javascript :: wait for the dom to load javascript 
Javascript :: how to check if 2 images are touching js 
Javascript :: expressjs hello world 
Javascript :: classname toggle js 
Javascript :: fetch then then return value 
Javascript :: window.ReactNativeWebView.postMessage 
Javascript :: get index of option in select jquery 
Javascript :: randomColor 
Javascript :: how to remove the last character from a string in javascript 
Javascript :: change onclick attribute javascript 
Javascript :: js addeventlistener mouseout 
Javascript :: jquery change picture source 
Javascript :: get value of input element on button click react 
Javascript :: initialize json array 
Javascript :: javascript random char 
Javascript :: connecting to mongodb using mongoose 
Javascript :: Syntax for creating a specific version of react app 
Javascript :: javascript appendchild at index 
Javascript :: How to more than one slot in graph node in godot 
Javascript :: convert responsetext to json python 
Javascript :: LogBox 
Javascript :: check if a string is alphanumeric 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =