Created
August 13, 2021 14:47
-
-
Save joshuaebowling/3bd3fa9e4c1221262d38d0cf655c2b1d to your computer and use it in GitHub Desktop.
Typescript Response Model for normalizing responses from functions/methods
This file contains 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
export interface IResponse<T> { | |
Message: string | |
IsError: boolean | |
Data: T | |
} |
This file contains 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 { IResponse } from "./IResponse" | |
export class Response<T> implements IResponse<T> { | |
Message: string = "" | |
Data: T | null = null | |
IsError: boolean = false | |
constructor(Data: T, Message: string = "", IsError: boolean = false) { | |
this.Data = Data | |
this.Message = Message | |
this.IsError = IsError | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment