Handle callback and promise responses
mainDepending on how you call the API, the response format differs:
Using Callbacks If a callback is provided, it receives two arguments:
err: A JavaScriptErrorobject if the request failed.data: An object containing the responseheadersandbody.
Using Promises
If no callback is provided, the method returns a Promise that resolves to the same data object ({ headers, body }) or rejects with an err.