Skip to content
Discussion options

You must be logged in to vote

You need to use arrow functions. this gets redefined in standard functions so it won't point to your alpine component (It's not an Alpine thing, it's how javascript works).

axios.get('https://jsonplaceholder.typicode.com/todos/')
  .then((response) => {
    this.todos = response.data;
    this.count = this.todos.length;
    console.log('Count', this.count);
 }).catch((error) => {
    console.log(error);
}).then(function () {
    // always executed
});

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@josejachuf
Comment options

Answer selected by josejachuf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants