| 11 | deleteBtn.addEventListener('click',deletedata); |
| 12 | |
| 13 | function getdata(){ |
| 14 | |
| 15 | const xhr = new XMLHttpRequest(); |
| 16 | |
| 17 | xhr.open('GET',`https://mashape-community-urban-dictionary.p.rapidapi.com/define?term=${inputtext.value}`,true); |
| 18 | xhr.setRequestHeader("x-rapidapi-key", "3713d5b39dmshf1764344d8244d5p116e9ajsneb81024be405"); |
| 19 | xhr.setRequestHeader("x-rapidapi-host", "mashape-community-urban-dictionary.p.rapidapi.com"); |
| 20 | |
| 21 | xhr.onload = function(){ |
| 22 | const response = xhr.responseText; |
| 23 | const obj = JSON.parse(response); |
| 24 | // console.log(obj.list[0]); |
| 25 | str = str + `<strong>${inputtext.value} </strong><li> ${obj.list[0].definition}</li> <br>`; |
| 26 | show.innerHTML = str; |
| 27 | // inputtext.value = ""; |
| 28 | } |
| 29 | |
| 30 | |
| 31 | xhr.send(); |
| 32 | } |
| 33 | |
| 34 | function deletedata(){ |
| 35 | show.innerHTML = ""; |