Skip to content

Commit f4230bc

Browse files
committed
Deploy abhijithvijayan/kuttUrl-browser-extension to github.com/abhijithvijayan/kuttUrl-browser-extension.git:extension
1 parent 6e9f74f commit f4230bc

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

js/background.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,10 +2037,21 @@ async function getShortURL(API_key, URLtoShorten, password) {
20372037
});
20382038
shortLink = rawData.data.shortUrl; // returns the promise
20392039

2040-
console.log("Returning Promise!");
20412040
return shortLink;
20422041
} catch (error) {
2043-
console.log(error);
2042+
// https://gist.github.com/fgilio/230ccd514e9381fafa51608fcf137253
2043+
if (error.response) {
2044+
console.log(error.response.data);
2045+
console.log(error.response.status); // return error code
2046+
2047+
return error.response.status;
2048+
} else if (error.request) {
2049+
console.log(error.request);
2050+
} else {
2051+
console.log('Error', error.message);
2052+
}
2053+
2054+
console.log(error.config);
20442055
}
20452056
}
20462057

@@ -2050,7 +2061,6 @@ _scripts_vendor_browser_polyfill__WEBPACK_IMPORTED_MODULE_1___default.a.runtime.
20502061
if (request.msg == "start") {
20512062
// consume the promise
20522063
return getShortURL(request.API_key, request.pageUrl, request.password).then(shortLink => {
2053-
console.log("URL:" + shortLink);
20542064
return shortLink;
20552065
}).catch(err => {
20562066
console.log("Error Occured!");

js/popup.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,10 +1355,10 @@ document.addEventListener('DOMContentLoaded', () => {
13551355
shortUrl = response;
13561356
document.getElementById('url__content-inner').textContent = "Error!!"; // invalid response
13571357

1358-
if (shortUrl === undefined) {
1359-
document.getElementById('url__content-inner').textContent = "API Error!!";
1360-
} else if (shortUrl === null) {
1361-
document.getElementById('url__content-inner').textContent = "Something's wrong!!";
1358+
if (shortUrl === null) {
1359+
document.getElementById('url__content-inner').textContent = "Invalid Response!";
1360+
} else if (shortUrl === 429) {
1361+
document.getElementById('url__content-inner').textContent = "API Limit Exceeded!";
13621362
} else {
13631363
// update the content with shortened link
13641364
document.getElementById('url__content-inner').textContent = shortUrl; // fetch qrcode from http://goqr.me

0 commit comments

Comments
 (0)