I am trying to reuse the the data returned from promise here. But, the problem is, after the first call to

checkPromise

function, it immediately calls the second function, and the promise for the first function is not fulfilled, so it nevers returns any data, and hence it never enters the if clause. How to reuse promise?

You likely have a timing issue. Your apiCall() function is asynchronous. That means it finishes sometime later. As such, each time you call checkPromise(), all you're doing is starting a request and it finishes sometime later. So, you call it the first time and it starts a request (that has not finished yet). Then, your next call to checkPromise() gets called and it does it's if check before the first call has completed. Thus, it finds nothing in the cache yet.

Your code is running two requests in parallel, not one after the other.

If you actually want to wait until the first request is done before executing the second one, then you will have to actually structure your code to do that. You would need to make checkPromise() return a promise itself so code using it could known when it was actually done in order to execute something after it was done.

FYI, I don't see anything in your code that is actually related to reusing promises (which is something you cannot do because they are one-shot objects).