Let’s say you want to get some data for a user with User Id 1. You can pass this User Id to a function along with the callback function to get the data. The function will first assign a role for which we want the data and then call the remote API. To mimic the remote API call, I’m using a Promise with the setTimeout function. You’ll notice that there will be exactly 4 seconds delay before showing the response output.
Here’s how the output should look like: