Cosas .w.

This commit is contained in:
Daniel Cortés
2019-06-16 22:17:26 -04:00
parent 141d7eb729
commit 23942616f7
2 changed files with 14 additions and 1 deletions

View File

@@ -1,7 +1,14 @@
<template>
<div class="users">
<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">
<li v-for="{ name, email } in users">
<strong>Name:</strong> {{ name }},
@@ -32,6 +39,9 @@ export default {
.then(response => {
this.loading = false;
this.users = response.data;
}).catch(error => {
this.loading = false;
this.error = error.response.data.message || error.message;
});
}
}

View File

@@ -3,5 +3,8 @@
use Illuminate\Http\Request;
Route::get('/users', function() {
if(rand(1, 10) < 3) {
abort(500, 'We could not retrieve the users');
}
return factory('App\User', 10)->make();
});