EDIT: One of my coworkers just mentioned that the way IE handles toLocalDateString() is different than other browsers... Looks like I'll be using moment.js to handle this issue. Also, this question is a duplicate, not sure if I should delete it or not. Here's a great answer:
ToLocaleDateString() changes in IE11
I am seeing some strange behavior while making performing a GET request with angular. I am only seeing this issue in IE11; both Chrome and Firefox are fine. I am sending two dates via query string parameters. I am appending the string as follows:
import { Http, Response, RequestOptions, Headers } from '@angular/http';
....
var date1 = new Date();
var date2 = new Date();
var start = date1.toLocaleDateString();
var end = date2.toLocaleDateString();
var url = '/localhost/someEndPoint?start=' +
start +
'&end=' +
end +
'&value1=' +
data.value1 +
'&value2=' +
data.value2;
return this.http.get(url).
map((response: Response) => <any>response.json())
.publishReplay(1)
.refCount()
.catch(this.handleError);
When I check my network, I get strange characters in the url (not sure if they will show up here or not)
Request URL: http://localhost:37424/someEndPoint?start=â10â/â9â/â2018&end=â10â/â9â/â2018&value1=-1&value2=-1
If I were to hardcode those dates, the request goes through just fine. What's even more strange to me is that it will also work if I do (no hardcoding):
encodeURI(url);
I am sure I'm missing something, but things seem to point to IE doing something funky.