Cosas .w.
This commit is contained in:
@@ -1,7 +1,14 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="users">
|
<div class="users">
|
||||||
<div class="loading" v-if="loading">Loading...</div>
|
<div class="loading" v-if="loading">Loading...</div>
|
||||||
<div v-if="error" class="error">{{ error }}</div>
|
<div v-if="error" class="error">
|
||||||
|
<p>{{ error }}</p>
|
||||||
|
<p>
|
||||||
|
<button @click.prevent="fetchData">
|
||||||
|
Try again
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
<ul v-if="users">
|
<ul v-if="users">
|
||||||
<li v-for="{ name, email } in users">
|
<li v-for="{ name, email } in users">
|
||||||
<strong>Name:</strong> {{ name }},
|
<strong>Name:</strong> {{ name }},
|
||||||
@@ -32,6 +39,9 @@ export default {
|
|||||||
.then(response => {
|
.then(response => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.users = response.data;
|
this.users = response.data;
|
||||||
|
}).catch(error => {
|
||||||
|
this.loading = false;
|
||||||
|
this.error = error.response.data.message || error.message;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,5 +3,8 @@
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
Route::get('/users', function() {
|
Route::get('/users', function() {
|
||||||
|
if(rand(1, 10) < 3) {
|
||||||
|
abort(500, 'We could not retrieve the users');
|
||||||
|
}
|
||||||
return factory('App\User', 10)->make();
|
return factory('App\User', 10)->make();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user