-1

I have specific problem with axios to getting JSON object from my arraylist, so instead of display my displayName on my nav bar, it display all response headers information, i don't know why ? :

enter image description here

that my json list from my localhost :

enter image description here

that my code :

<a class="nav-link dropdown-toggle text-nowrap px-3" v-d-toggle.user-actions>
    <img class="user-avatar" src="@/assets/images/avatars/0.jpg" alt="User Avatar"> 
    <span class="d-none d-md-inline-block"></span>{{jsonInfo}}
</a>

<script>
 import axios from 'axios'; 

 export default {
  data() {
  return {
      jsonInfo: [],
      
    }
 },
 mounted () {
  axios
   .get('http://localhost:5000/info/users')
   .then(response => (this.jsonInfo = response))
  
   }
 }
</script>

1 Answer 1

1

Take a look at the axios docs. The response object contains much more than the data that you are requesting. If you are wanting the data in your jsonInfo array, you will want response.data instead of the full response object.

Sign up to request clarification or add additional context in comments.

3 Comments

@b-blox hi, i already try with response.data and i obtain empty array on my navbar
@TheRevenant95 As your data is containing empty array. Hence it is returning an empty array.
@Rohìt-Jíndal Yep i fix that 👍

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.