menu

Questions & Answers

throwing Warning: a promise was rejected with a non-error: [object Object]
  function fetch(options) {
   return new Promise((resolve, reject) => {
     this.request(options, (err, response, status, xhr) => {
     console.log('err res', err, response);//#console2
     return err ? reject(err) : resolve(response);
     });
   });
  }

This is my block of code. I have already seen a lot of related questions but still couldn't find anything. In my case, I'm calling this fetch method from 2 places within a project with the same input and I'm getting the same error for both the time i.e till #console2 everything is the same but while returning one time it is throwing warning promise was rejected with a non-error: and for another call, it is not throwing anything. Please let me know if anyone is aware of this issue. Thanks in advance :) .

Comments:
2023-01-07 20:33:00
I assume your code is meant to say function fetch(..... ?
2023-01-07 20:33:00
yes, I have corrected the question.
2023-01-07 20:33:00
Warnings are not thrown.
2023-01-07 20:33:00
You'll need to show us what this.request does. Apparently it sometimes calls its callback with a non-Error value for the err parameter.
2023-01-07 20:33:00
this.request just calls the API and its same bor both the time.
2023-01-07 20:33:00
till console2 everything is same for both time.
2023-01-07 20:33:00
Again, please edit your question to post the code of this.request and show us how it is calling the callback function. We cannot help you otherwise. That it works for another request does not matter, apparently the code is doing something different (probably due to receiving a different response) there.
Answers(0) :