0
respostas

401 (Unauthorized) JWT VUEjs

Olá galera, todos bem?

Estou com o seguinte problema ao consumir API. Para Beckend estou usando Laravel 8 e para Frontend VueJs.

composables/profile.ts

import http from "../http/index"
import { ref } from 'vue'

export default function Profile() {
    const profile = ref([])
    const errors = ref('')

    let headers = {
        'Accept': 'application/json',
        'Authorization': 'Bearer ' + localStorage.getItem('token'),
    }

    const getProfile = async () => {
        let response = await http.post('me', headers)
        profile.value = response.data
    }

    return {
        profile,
        errors,
        getProfile,
    }
}

Ao tentar consumir a API pelo Postman eu obtenho os dados normalmente, mas ao tentar pelo código acima tenho o erro de 401 (Unauthorized). Obrigado pela ajuda, pessoal!