Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove promise for loader #1

Open
kenjiSpecial opened this issue Feb 12, 2019 · 2 comments
Open

remove promise for loader #1

kenjiSpecial opened this issue Feb 12, 2019 · 2 comments

Comments

@kenjiSpecial
Copy link
Owner

No description provided.

@kenjiSpecial
Copy link
Owner Author

kenjiSpecial commented Feb 12, 2019

export function getAjaxJson(url: string, callback: Function) {
	// return new Promise((resolve: (val: string) => void, reject: (val: number) => void) => {
	// the resolve / reject functions control the fate of the promise
	const xhr = new XMLHttpRequest();
	xhr.open('GET', url, true);

	xhr.onreadystatechange = () => {
		if (xhr.readyState === 4) {
			if (xhr.status === 200) {
				const resp: string = xhr.responseText;
				const respJson = JSON.parse(resp);
				callback(respJson);
				// resolve(respJson);
			} else {
				// reject(xhr.status);
			}
		} else {
			// reject(xhr.status);
		}
	};

	xhr.send();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant