-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathece.js
More file actions
32 lines (23 loc) · 853 Bytes
/
ece.js
File metadata and controls
32 lines (23 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const getTodos = (resource, callback) => {
const request = new XMLHttpRequest();
request.addEventListener("readystatechange", () => {
if (request.readyState === 4 && request.status === 200) {
const data = JSON.parse(request.responseText);
callback(undefined, data);
} else if (request.readyState === 4) {
callback("başarılı cevap alamadım", undefined);
}
});
request.open("GET", resource);
request.send();
};
// Doğru dosya yolu olduğundan emin olun
getTodos("example/can.json", (err, data) => {
console.log(data);
getTodos("example/osman.json", (err, data) => {
console.log(data);
getTodos("example/tuba.json", (err, data) => {
console.log(data);
});
});
});