简体   繁体   中英

how to get the value of a http request response in vuejs

Actually what I wants to know is how to get the value of the name in Vuejsof a http request.Please see the image for the Chrome console click here to see the console to get the value of name i have written below code at Register.vue .But after user registration it shows under application tab of chrome name is undefined.

 .then((response) => {
      console.log(response)
      let accessToken = response.data.access_token
      localStorage.setItem('token', accessToken)
      localStorage.setItem('user', response.config.data.name)

So could anyone please tell me how to get the value of name.

response.config.data is a String (see the double qoutes). You need to parse it (JSON.parse) and then you can take the name property.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM