Skip to content

Commit 7c53b62

Browse files
committed
Links to the Full API results
1 parent 75be33a commit 7c53b62

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

build/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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
};

src/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export class OpenCageServer {
116116
params.append('bounds', bounds);
117117
}
118118

119-
const response = await fetch(`${OPENCAGE_API_URL}?${params}`);
119+
const url = `${OPENCAGE_API_URL}?${params}`;
120+
const response = await fetch(url, { headers: HEADERS });
120121
const data: OpenCageResponse = await response.json();
121122

122123
if (data.status.code !== 200) {
@@ -163,7 +164,7 @@ export class OpenCageServer {
163164
` Currency: ${r.currency.name} (${r.currency.iso_code})`,
164165
)
165166
.join('\n\n')}` +
166-
`\n\nFull API response:\n${JSON.stringify(data, null, 2)}`,
167+
`\n\nLink to the full API response:\n${url}\nCopy/paste this link to view the full response.`,
167168
},
168169
],
169170
};
@@ -203,7 +204,9 @@ export class OpenCageServer {
203204
params.append('no_annotations', '1');
204205
}
205206

206-
const response = await fetch(`${OPENCAGE_API_URL}?${params}`);
207+
const url = `${OPENCAGE_API_URL}?${params}`;
208+
209+
const response = await fetch(url);
207210
const data: OpenCageResponse = await response.json();
208211

209212
if (data.status.code !== 200) {
@@ -242,7 +245,7 @@ export class OpenCageServer {
242245
`Flag: ${info.flag}\n` +
243246
`Timezone: ${info.timezone.name}\n` +
244247
`Currency: ${info.currency.name} (${info.currency.iso_code})\n` +
245-
`\nFull API response: ${JSON.stringify(data, null, 2)}`,
248+
`\n\nLink to the full API response:\n${url}\nCopy/paste this link to view the full response.`,
246249
},
247250
],
248251
};

0 commit comments

Comments
 (0)