superagent icon indicating copy to clipboard operation
superagent copied to clipboard

Get with queries not working in IE11 because of code using includes

Open valleywood opened this issue 4 years ago • 2 comments

Get promise throws an error on IE Object doesn't support property or method 'includes'

The get function wrapped into the promise below will throw an exception on IE

      get(config.baseUrl +'/api/xyz')
        .set('Accept', 'application/json')
        .set('Cache-Control', 'no-store')
        .query({ x: y, y: z })
        .end(function(error, res) {
          if (res.status === 404 || error) {
            resolve(null);
          } else {
            resolve(JSON.parse(res.text));
          }
        });
    });

Seeing a lot of includes functionality in the code (request-base.js) : if (err.code && ERROR_CODES.includes(err.code)) return true;

this.url += (this.url.includes('?') ? '&' : '?') + query;

valleywood avatar May 18 '20 12:05 valleywood

Same. I temporary fixed importing includes from core-js at top level:

import 'core-js/features/string/includes';
import 'core-js/features/array/includes';

lorenzos avatar Jun 19 '20 16:06 lorenzos

it looks like the changes made in https://github.com/visionmedia/superagent/commit/7d70a7559d4df3e10ebcece0cf319083184278dc broke the pupported IE11 compatibility by changing lots of things to includes rather than indexOf

chadlwilson avatar Jan 17 '21 15:01 chadlwilson