sipgate rest api client v2
Client for the sipgate rest api v2.
This version is still under development and therefore subject to change.
Response error handling
Since version 5.0.0
all responses with a non-2xx status code result in a rejected promise. You can access response details through the payload
property of the resulting error that fulfills the ResponseErrorPayload
interface.
Example
;const client = ; client ;
Legacy response error handling
In versions prior 5.0.0
HTTP response errors were not handled correctly. On receiving a non-2xx HTTP response, your promise was not rejected but fulfilled with the error HTTP response body. If you need to keep the old behavior set the fourth parameter skipResponseErrorHandling
of createClient
to true
.
Example
; const handlePromiseResolved = { if !responsestatus >= 200 && responsestatus < 300 throw "Received invalid API response"; return response;}; const client = ;
You should use the third parameter onPromiseResolved: ((Response) => Response | PromiseLike<Response>)
of createClient
to implement your own error handling. The function you provide is executed as part of the promise handling chain.
Publish to NPM repository
Just publish with yarn.
yarn publish
This also commits and pushes any changes done by that command.