I am developing with Nuxtjs and using nuxtauth.
I am trying to give the content " JWT " to the Authorization of http request.
However, even if I change the string to be given by coding, "Bearer " is sent and I get a 401 error.
The formed text (including the JWT) can be seen in the console.
The process is as follows.
<template>
<div>
<button @click="getUserInfo">get user data</button>
<div>
{{ responseData }}
</div>
</div>
</template>
<script>
export default {
data() {
return {
pretoken: this.$auth.strategy.token.get(),
responseData: {}
};
},
methods: {
async getUserInfo() {
const url = "/server/v1/mypages/";
const pretoken = this.pretoken;
const fixedtoken = pretoken.replace("Bearer", "JWT");
console.log(fixedtoken);
this.$axios.setHeader("Authorization", fixedtoken);
this.responseData = await this.$axios.get(url);
}
}
};
</script>
How can I achieve this?