Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

authentication in strapi

import axios from 'axios';

const { data } = await axios.post('http://localhost:1337/api/auth/local', {
  //identifier is email or username
  identifier: 'reader@strapi.io',
  password: 'strapi',
});

console.log(data);

//data 
{
    "jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNTc2OTM4MTUwLCJleHAiOjE1Nzk1MzAxNTB9.UgsjjXkAZ-anD257BF7y1hbjuY3ogNceKfTAQtzDEsU",
    "user": {
        "id": 1,
        "username": "reader",
        ...
    }
}
 
PREVIOUS NEXT
Tagged: #authentication #strapi
ADD COMMENT
Topic
Name
4+7 =