xenoterracide xenoterracide - 2 months ago 11x
TypeScript Question

How can I return my own promise?

I'm working setting up my internal service API for Aurelia, I want to return a Promise that I wrote myself and worry about using fetch later. I set Aurelia up to use Bluebird. How can I manually create the promise to return from a method without getting actual http involved?

I imagine it's basically

doAndReturn(): Promise<MyType> {
... stuff
return ... magic create Promise?


It sounds like you are wanting to mimic what happens when a promise is resolved and returned, is that correct?

It sounds like your function just needs to return Promise.resolve(value)

doAndReturn(): Promise<MyType> {
    return Promise.resolve(true);

keep in mind your return type on the function is expecting a Promise to return a value of type MyType