Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to authenticate token in react using axios

const api = `your api here`
axios.get(api, { headers: {"Authorization" : `Bearer ${token}`} })
        .then(res => {
            console.log(res.data);
        this.setState({
            items: res.data,  /*set response data in items array*/
            isLoaded : true,
            redirectToReferrer: false
        })
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #authenticate #token #react #axios
ADD COMMENT
Topic
Name
9+6 =