D
D
DrunkMaster2017-03-18 09:11:02
Vue.js
DrunkMaster, 2017-03-18 09:11:02

How to display usernames on the page?

Just started learning how to work with vue.
I'm trying to reproduce the functionality of ajax requests https://jsfiddle.net/L1jr5j1g/
1) Do I understand correctly that vue itself does not know how to ajax and you need to connect vue-resource? (which is done)
2) How can I get and display just any text that the requested page gives me in order to understand that at least something works
3) I have a browser plugin for vue debug, then debug: true inside data and everything is silent, the console in the code inspector for this case does not show any errors and warnings.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Bogachev, 2017-03-18
@DrunkMaster

Do I understand correctly that vue itself does not know how to use ajax and it is necessary to connect vue-resource?

Vue-resource is no longer the "officially recommended" solution. You can use the same axios or regular fetch and substitute a polyfill for it.
If you are using vue-resource (I see it is present in the demo) - take a closer look at the usage example .
In jsfiddle, it is generally problematic to debug something, because this extension does not know how to work with code inside an iframe.
Enable babel to use arrow functions and not bother with context, and write something like this:
request: function() {
    this.$http.get('http://jsonplaceholder.typicode.com/users')
        .then(response => {
            this.users = response.body;
        });
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question