-
Notifications
You must be signed in to change notification settings - Fork 2
/
etimolojiturkce.js
37 lines (30 loc) · 1.03 KB
/
etimolojiturkce.js
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
32
33
34
35
36
37
function etimolojiTurkceApi(type, word, read, quant){
var xhr = new XMLHttpRequest();
xhr.open("GET", "https://api.etimolojiturkce.com/"+type+"/"+word+"&q="+quant, true);
xhr.responseType = "text";
xhr.onload = function() {
var status = xhr.status;
if (status == 200) {
read(JSON.parse(xhr.responseText));
}
};
xhr.send();
}
//Examples
/*
etimolojiTurkceApi("word", "sadasd", function(w){
console.log(w); // word does not exist
}, 1);
etimolojiTurkceApi("word", "mahal", function(w){
console.log(w); // returns word
}, 1);
etimolojiTurkceApi("search", "aba", function(w){
console.log(w); // returns search result
}, 10);
etimolojiTurkceApi("word", "random", function(w){
console.log(w); // returns random words
}, 5);
etimolojiTurkceApi("word", "random", function(w){
console.log(w); // returns one random word data
}, 0);
*/