I have a couple of questions about Dwolla’s thenable api.
-
Does client.auth.client() return a promise? What happens if I chain .then() to it many times?
-
Is appToken a promise? What happens if I chain .then() to it many times?
-
Question on the asynchronous nature of the API. Suppose I’m trying to remove a funding source and adding a new one with duplicate info. What happens if I attempt to create a duplicate funding source (same bank account) before the funding source can be removed? How do I “wait” for all of a customer’s funding sources to be removed before attempting to add a new funding source?
If I add a .then() to client.auth.client() after appToken.post(…).then(…), is there a way I can guarantee it to run after the appToken “post” request as completely finished and the “then” callback after appToken has finished running? I mean like in the following:
client.auth.client()
.then(appToken => {
return appToken.post(".....")
.then(resp => {
// do something with resp
})
}).then() <--- this is the "then" I'm talking about; is there a way
to ensure that this runs last?
Suppose I have an array, of arbitrary length, of funding source URLs that I want to “remove.” Is there a way I can have a callback/.then() that is guaranteed to run AFTER all of funding sources are finished being removed? On the other hand, is there a way I can get a callback to run IMMEDIATELY after the last funding source has been removed?
let fundingSources = [...];
client.auth.client()
.then(appToken => {
return appToken.post(".....", {removed: true})
.then(resp => {
// do something with resp
});
});