Created
December 27, 2018 06:41
-
-
Save knrt10/a8173771ef8f193a100b87d2f56dcadb to your computer and use it in GitHub Desktop.
Sending response on completing the promise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Response } from "../models"; | |
| export function completeRequest(promise: Promise<Response>): any { | |
| const res = promise.then((response) => { | |
| const finallResponse = { | |
| code: response.code, | |
| message: response.message, | |
| data: response.data, | |
| }; | |
| return finallResponse; | |
| }).catch((errorRes) => { | |
| const finallResponse = { | |
| code: errorRes.code, | |
| message: errorRes.message, | |
| data: errorRes.data, | |
| }; | |
| return finallResponse; | |
| }); | |
| return res; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment