Skip to content

Make promises simpler for the best case #7

@davidhariri

Description

@davidhariri

Simplify the best case from this:

Net
.delete(`${APIROOT}/expressions/${expression_id}`)
.then((APIResponse) => {
    if(APIResponse.status.code == 200) {
        // Good stuff...
    } else {
        // Bad stuff...
    }
}).error((APIResponse) => {
   // An exception was thrown
});

To this:

Net
.delete(`${APIROOT}/expressions/${expression_id}`)
.then((statusCode, jsonContent, responseObject) => {
    // Good Stuff (got a code < 304)
}).error((statusCode, jsonContent, responseObject) => {
    // Bad Stuff ( got a code > 304)
    // If this is an exception, the jsonContent will be the exception string and the responseObject will be the trace and the code will be 0
});

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions