UrielCh / api-ovh-node

a TypeScript helper to use OVH API
MIT License
16 stars 5 forks source link

handle HTTP status code 204 #10

Closed aperron closed 3 years ago

aperron commented 3 years ago

Hello,

Only the http 200 status code is taken into account, but OVH seems to respond with a code 204.

So I have this kind of error:

// pseudo code
cloud.kube.NodePool.$(nodepoolId).$put({
   maxNodes: 5
})
/apps/ovh_cli/node_modules/@ovh-api/api/dist/index.js:436
                error.errorCode = "HTTP_ERROR";
                                ^
TypeError: Cannot create property 'errorCode' on string ''
    at handleResponse (/apps/ovh_cli/node_modules/@ovh-api/api/dist/index.js:436:33)
    at IncomingMessage.<anonymous> (/apps/ovh_cli/node_modules/@ovh-api/api/dist/index.js:477:28)
    at IncomingMessage.emit (node:events:381:22)
    at IncomingMessage.emit (node:domain:470:12)
    at endReadableNT (node:internal/streams/readable:1307:12)
    at processTicksAndRejections (node:internal/process/task_queues:81:21)

It may be possible to expand to all code 2XX

UrielCh commented 3 years ago

I never used kube.

change your cote to (statusCode >= 200 && statusCode < 300) I do not want to add patch for any future 2XX codes

aperron commented 3 years ago

Done :+1:

UrielCh commented 3 years ago

Compilation, failed, then fixed.

Next release is out.