[Vuejs]-How return json object when visits a url in webpack vue development project?

0👍

The webpack template has a history api fallback plugin, which automatically serve your index page (usually index.html) when /users is not found on the server, so you may check whether your are defining and visiting /users correctly, or even remove the plugin and see if /users return 404.

-1👍

How you serve that data dependes on what technology you’re using on server side for example if you’re using .net you could serve data trout an ApiController, in node you could use Express or any other middleware or JAX-RS in java.

In your client side exists different alternatives, I think that most common is to use vue-resource plugin, you need to install it and then use it as follows

  this.$http
   .get('/someUrl')
   .then((response) => {
      // success callback
    }, (error) => {
      // error callback
    });

Leave a comment