reactjs - Ajax Promise does not return to component when called from lifecycle method -


single page app. react router. webpack. testing on devserver.

i trying promise-based ajax request inside componentdidmount() lifecycle method. unfortunately response not return calling function. occurs both axios , fetch polyfill.

here photo album of chrome debugger network log. chrome says request good, , server says good. chrome shows duplicate request "stalled".

the first request (login?email&pass) axios promise fired button click in statefull component. on success, redirect component, profile. profile makes (loggedin) request componentdidmount() method.

even if 'doing react/async wrong', shouldn't able ajax promises componentdidmount()?

componentdidmount() {     this.loaddata() }     

which calls...

loaddata(){   axios.request({      method: 'post',      url: 'http://localhost:3000/loggedin',      data: {          //session      }   })     .then(function(result){         console.log(result)         this.setstate({         user: result.data.user     }) })     .catch(function(err){         console.log(err)     }); } 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -