Find answers, ask questions, and connect with our
community around the world.

Forums Forums Web Design How to use callback with API call wrapper function?

  • How to use callback with API call wrapper function?

    updated 11 months, 1 week ago 0 Member · 1 Post
  • BusinessMag

    October 27, 2021 at 1:03 pm

    So I have a function let’s say getAllFruits() that calls an api listAllfruits. What I want to do once getAllFruits() is complete I want to set some flag. But how can I do that without using then or arrow function? Basically I guess I will have to a callback but I am not able to figure out the syntax. Here’s a snippet: getAllFruits() { … api.listAllfruits(error, data, response){ … If(error){ … } elseif(response){ … } } … } Now I have this function: doThisOnClick() { Flag = 0; //once the api call completes getAllFruits (){ //this is not correct Flag = 1; } } Ps- I am new pls help. Sorry Ik this looks bad but typing it on my cellphone. – by /hq/dennkiesauros – –

Viewing 1 of 1 replies
Reply to: BusinessMag
Your information:

Original Post
0 of 0 posts June 2018