No data shows when i add find(Auth::id()) But with find(1); data retrieves.
Axios script
export default {
data () {
return {
jobs: []
}
},
mounted() {
axios
.get('/api/dashboard')
.then(response => (this.jobs = response.data))
},
}
api.php router
Route::middleware('auth:api')->get('/user', function
(Request
$request) {
return $request->user();
});
Route::resource('dashboard', 'HomeController');
Homecontroller
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\User;
public function index(){
return User::find(Auth::id());
}
No data shows when i add find(Auth::id()) But with find(1); data retrives.
Auth::id()?index()method does not return anything. Try usingreturn User::find(Auth::id());