I am making request to an api, and they(API owners) mentioned that their response can be immediate and also can be delayed sometimes like sometimes it will be 2 hours but I have to do action on basis of that response. What process should I go with? should I use timers, cron jobs or any better way you can suggest.
//axios,other stuff
const getUsersList = async (req, res) => {
axios
.get("https://thirdparty.com/api/some_url/" + req.params.email)
.then((res) => {
//this action i want to perform on response but it comes after two hours mostly
await User.create({
firstName: res.data.first_name,
});
});
res.status({ message: "your details are saved" });
};
I can't make someone wait for two hours as it will be bad User experience, so what is the procedure to go with?