File tree 3 files changed +105
-0
lines changed
3 files changed +105
-0
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "word" : " amazing" ,
3
+ "results" : [
4
+ {
5
+ "definition" : " inspiring awe or admiration or wonder" ,
6
+ "partOfSpeech" : " adjective" ,
7
+ "synonyms" : [
8
+ " awe-inspiring" ,
9
+ " awesome" ,
10
+ " awful" ,
11
+ " awing"
12
+ ],
13
+ "similarTo" : [
14
+ " impressive"
15
+ ],
16
+ "examples" : [
17
+ " New York is an amazing city"
18
+ ]
19
+ },
20
+ {
21
+ "definition" : " surprising greatly" ,
22
+ "partOfSpeech" : " adjective" ,
23
+ "synonyms" : [
24
+ " astonishing"
25
+ ],
26
+ "similarTo" : [
27
+ " surprising"
28
+ ],
29
+ "examples" : [
30
+ " she does an amazing amount of work"
31
+ ]
32
+ }
33
+ ],
34
+ "syllables" : {
35
+ "count" : 3 ,
36
+ "list" : [
37
+ " a" ,
38
+ " maz" ,
39
+ " ing"
40
+ ]
41
+ },
42
+ "pronunciation" : {
43
+ "all" : " ə'meɪzɪŋ"
44
+ },
45
+ "frequency" : 4.94
46
+ }
Original file line number Diff line number Diff line change
1
+ console . log ( 'Hello' ) ;
2
+ str = "" ;
3
+
4
+ const fetchBtn = document . getElementById ( 'fetchBtn' ) ;
5
+ const deleteBtn = document . getElementById ( 'deleteBtn' ) ;
6
+
7
+ const inputtext = document . getElementById ( 'inputtext' ) ;
8
+ const show = document . getElementById ( 'list' ) ;
9
+
10
+ fetchBtn . addEventListener ( 'click' , getdata ) ;
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 = "" ;
36
+ str = "" ;
37
+ }
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
6
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
+ < title > Get Words Definitions</ title >
8
+ </ head >
9
+ < body >
10
+ < h1 > Welcome to The Dictionary </ h1 >
11
+
12
+ < input type ="text " id ="inputtext ">
13
+ < button id ="fetchBtn " style ="height: 30px; margin: 20px; background-color: rgb(26, 211, 224); border-radius: 7px; font-family: 'Franklin Gothic Medium'; "> Fetch</ button >
14
+ < button id ="deleteBtn " style ="height: 30px; background-color: greenyellow; border-radius: 7px; font-family: 'Franklin Gothic Medium'; "> Delete All</ button >
15
+
16
+ < h2 > Defenition</ h2 >
17
+ < ul id ="list ">
18
+
19
+ </ ul >
20
+ < script src ="app.js "> </ script >
21
+ </ body >
22
+ </ html >
You can’t perform that action at this time.
0 commit comments