@@ -56,7 +56,8 @@ export class OpenCageServer {
5656 if ( bounds ) {
5757 params . append ( 'bounds' , bounds ) ;
5858 }
59- const response = await fetch ( `${ OPENCAGE_API_URL } ?${ params } ` ) ;
59+ const url = `${ OPENCAGE_API_URL } ?${ params } ` ;
60+ const response = await fetch ( url , { headers : HEADERS } ) ;
6061 const data = await response . json ( ) ;
6162 if ( data . status . code !== 200 ) {
6263 throw new Error ( `OpenCage API error: ${ data . status . message } ` ) ;
@@ -93,7 +94,7 @@ export class OpenCageServer {
9394 ` Timezone: ${ r . timezone . name } \n` +
9495 ` Currency: ${ r . currency . name } (${ r . currency . iso_code } )` )
9596 . join ( '\n\n' ) } ` +
96- `\n\nFull API response:\n${ JSON . stringify ( data , null , 2 ) } ` ,
97+ `\n\nLink to the full API response:\n${ url } \nCopy/paste this link to view the full response. ` ,
9798 } ,
9899 ] ,
99100 } ;
@@ -128,7 +129,8 @@ export class OpenCageServer {
128129 if ( no_annotations ) {
129130 params . append ( 'no_annotations' , '1' ) ;
130131 }
131- const response = await fetch ( `${ OPENCAGE_API_URL } ?${ params } ` ) ;
132+ const url = `${ OPENCAGE_API_URL } ?${ params } ` ;
133+ const response = await fetch ( url ) ;
132134 const data = await response . json ( ) ;
133135 if ( data . status . code !== 200 ) {
134136 throw new Error ( `OpenCage API error: ${ data . status . message } ` ) ;
@@ -162,7 +164,7 @@ export class OpenCageServer {
162164 `Flag: ${ info . flag } \n` +
163165 `Timezone: ${ info . timezone . name } \n` +
164166 `Currency: ${ info . currency . name } (${ info . currency . iso_code } )\n` +
165- `\nFull API response: ${ JSON . stringify ( data , null , 2 ) } ` ,
167+ `\n\nLink to the full API response:\n ${ url } \nCopy/paste this link to view the full response. ` ,
166168 } ,
167169 ] ,
168170 } ;
0 commit comments