How do I use callbacks (onSuccess and onError) to consume the API/Query response?

We could use JS function/promises to show alters after the APIs are consumed. Following is a code snippet that you could use in JS Objects:

export default {
    myFun1: () => {
        {{Api1.run(() => showAlert("Success"), () => showAlert("Failure"))}}
    },
    myFun2: async () => {
        //use async-await or promises
    }
}

To know more about promises and callbacks read our documentation here: