When I use axios I got this error:
[Vue warn]: Error in created hook: "TypeError: Cannot read property 'get' of undefined"
export default {
methods: {
loadUsers(){
axios.get("api/user").then(data => (this.users = data));
}
},
created() {
this.loadUsers();
}
}
Routes: api.php
Route::apiResources(['user' => 'API\UserController']);
Controller: API/UserController.php
public function index()
{
return User::latest()->paginate(5);
}
axios
isundefined
, did you import it? – thanksdimport {AxiosInstance as axios} from "axios";
When remove this, there has no error. – Md. Nayem