Skip to content

Instantly share code, notes, and snippets.

@joshuaebowling
Created August 13, 2021 14:47
Show Gist options
  • Save joshuaebowling/3bd3fa9e4c1221262d38d0cf655c2b1d to your computer and use it in GitHub Desktop.
Save joshuaebowling/3bd3fa9e4c1221262d38d0cf655c2b1d to your computer and use it in GitHub Desktop.
Typescript Response Model for normalizing responses from functions/methods
export interface IResponse<T> {
Message: string
IsError: boolean
Data: T
}
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