I am working on an Axios request to retrieve some data and store it in local storage. My goal is to make another request once the first one is complete, using the response data from the initial request.
this.$http.post("http://localhost:8000/oauth/token", data).then(response => {
this.$auth.setToken(
response.data.access_token,
response.data.expires_in + Date.now()
);
}).then(()=>{
this.$http.get("user").then(response => {
this.$auth.setAuthenticatedUser(response.data);
this.user = response.data;
this.image = response.data.image;
this.$bus.$emit('logged_user',response.data);
});
this.$http
.get("http://localhost:8000/api/tpa/provider/status")
.then(res => {
localStorage.setItem("tpa_provider", JSON.stringify(res.data));
});
this.$bus.$emit('logged_user',this.user);
if(this.$auth.isAuth()){
this.$router.push({"name":"home"});
}
I have also attempted to use async/await but have not been successful in achieving the desired outcome.