4 ms·
I just use this https://labs.omniti.com/labs/jsend https://labs.omniti.com/labs/jsend and typed it up via TS. It makes for nice code. Promise<JSendApiResp
by noir_lord 8y ago
I just use this https://labs.omniti.com/labs/jsend https://labs.omniti.com/labs/jsend and typed it up via TS.
It makes for nice code.
Promise<JSendApiResponse>
With the benefit of HTTP level stuff not been mapped onto application level stuff.
I like KISS with this kind of thing and if you need a more complex solution it handles that as a starting point.
- indexerror 8y agoYou can do this with Axios too: interface IResponse { foo: string } async function doSomething() { const reponse: AxiosResponse<IResponse> = await Api.call() ... // or you can use AxiosPromise<IResponse> without the await }