update webs docs
This commit is contained in:
38
nicetechcg/server/response.js
Normal file
38
nicetechcg/server/response.js
Normal file
@@ -0,0 +1,38 @@
|
||||
class Response {
|
||||
constructor(data){
|
||||
this.code = 200
|
||||
this.msg = 'success'
|
||||
// this.data = data
|
||||
}
|
||||
}
|
||||
|
||||
class SuccessResponse extends Response {
|
||||
constructor(data){
|
||||
super(data)
|
||||
this.data = data
|
||||
}
|
||||
}
|
||||
|
||||
class ErrorResponse extends Response {
|
||||
constructor(data){
|
||||
super(data)
|
||||
if(typeof data === 'string'){
|
||||
this.code = 500
|
||||
this.msg = data
|
||||
}
|
||||
if (typeof data === 'object'){
|
||||
this.code = 500
|
||||
this.msg = "error"
|
||||
this.data = data
|
||||
}
|
||||
if (data === "" || data === null || data === undefined){
|
||||
this.code = 500
|
||||
this.msg = "error"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
SuccessResponse,
|
||||
ErrorResponse
|
||||
}
|
||||
Reference in New Issue
Block a user