superagent
superagent copied to clipboard
Get with queries not working in IE11 because of code using includes
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;
Same. I temporary fixed importing includes
from core-js at top level:
import 'core-js/features/string/includes';
import 'core-js/features/array/includes';
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