Skip to content

Instantly share code, notes, and snippets.

View Srikanththyagarajan's full-sized avatar

Srikanth Thyagarajan Srikanththyagarajan

View GitHub Profile
@Srikanththyagarajan
Srikanththyagarajan / ajax-with-promise.ts
Created August 7, 2018 09:44 — forked from floriankraft/ajax-with-promise.ts
HTTP Request with Promises in Typescript
getRequest(url: string): Promise<any> {
return new Promise<any>(
function (resolve, reject) {
const request = new XMLHttpRequest();
request.onload = function () {
if (this.status === 200) {
resolve(this.response);
} else {
reject(new Error(this.statusText));
}