Authentication on Strapi

Login

import axios from 'axios';

axios
  .post('http://localhost:1337/auth/local', {
    identifier: 'user@strapi.io',
    password: 'strapiPassword',
  })
  .then(response => {
    //Store user token in cookie or localstorage, then use it in all next requests.
    console.log('Your user token', response.data.jwt);
  })
  .catch(error => {
    // Something wrong with auth. Wrong credentials maybe.
    console.log('An error occurred:', error.response);
  });

Get data as authenticated user

axios
  .get('http://localhost:1337/posts', {
    headers: {
      //Use token that you stored from previous request
      Authorization: `Bearer ${token}`,
    },
  })
  .then(response => {
    // Received all posts as authenticated user
    console.log('Posts: ', response.data);
  })