0

I am trying to get the page to render in my browser from the following code below in the promise because I only want to render it when the promise is resolved.However it keeps erroring and says that there is no render function. How do I return the following tag.

app.auth().currentUser.getIdToken(true).then(function(idToken) {
        accessToken = idToken;
        console.log(accessToken);
        config = {
            headers: {'Authorization': accessToken}
        };
        axios.get('http://localhost:4001/api/v1/page', config)
                .then(function (response) {
                    return (
                        <h1> test </h1>
                    ); 
                })
                .catch(function (error) {
                    console.log(error);
                });
    });
Coder1234
  • 389
  • 1
  • 3
  • 9
  • well... you don't. That's just not possible. You don't want each call to .render to have to wait on an async call. The async call should instead cause a render to occur with the result. – Kevin B May 08 '19 at 18:39
  • How should I change my code to do this – Coder1234 May 08 '19 at 18:43
  • 1
    A promise is a way to encapsulate a future value to an operation that could take a while to complete. The return value of `axios.get()`, a Promise, is the value you may want to return here. It'll then be up to whoever consumes this return value to use `.then()` to consume the actual future value. – ctt May 08 '19 at 18:45
  • How do I return axios.get – Coder1234 May 08 '19 at 19:08

0 Answers0