Home>

NuxtFrom the screenemailWhenpasswordSendrailsofdevise_token_authAuthentication with,
access-token/client/uidReceived in response`localStorageI want to save to.

CurrentlyPostmanRegistration&login by hitting the API with is working,PostmanAboveHeadresIs also displayed.

Even when hit with a command, it is the same as in the state below.

$curl localhost:3000/api/v1/auth/sign_in -X POST -d'{"email":"[email protected]", "password":"password"}' -H "content-type:application/ json" -i
Result =>
HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1;mode=block
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: strict-origin-when-cross-origin
Content-Type: application/json;charset=utf-8
access-token: C3x1Ujg7bflWSEEGwud_IA
token-type: Bearer
client: LEhRpZ8xwR98ENl7uW60hQ
expiry: 1594658783
uid: [email protected]
ETag: W/"1f7997550c2a07d9d9739f64d4dfd8e5"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: e7c26e6d-eae5-4cfe-b2a6-52f9990629c8
X-Runtime: 0.289309
Vary: Origin
Transfer-Encoding: chunked

And to get the response header information by hitting api, do the following:NuxtAppPluginsIt is described in.

export default function ({ $axios }) {
  $axios.onResponse(response =>{
    if (response.headers.client) {
      localStorage.setItem('access-token', response.headers['access-token'])
      localStorage.setItem('client', response.headers.client)
      localStorage.setItem('uid', response.headers.uid)
      localStorage.setItem('token-type', response.headers['token-type'])
    }
  })
}

Andresponse.headersThe contents returned as are as follows.

accept-ranges: "none"
connection: "keep-alive"
content-length: "2787"
content-type: "text/html;charset=utf-8"
date: "Mon, 29 Jun 2020 17:14:15 GMT"
etag: ""ae3-Jb4rA/MdMTBwjZG+5o//VVym57U""

I feel like I'm doing something quite out of the question that something completely different is coming back, but I'm really into it. .. ..
I would appreciate it if you could help me. Thank you.

  • Answer # 1

    Auth Moduleofthis.$auth.loginWithIf you hit it directly without hitting the API withheadersI was able to get it properly.
    I was thinking about linking it, but I wonder if there isn't something like that...?