aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-06-05 07:58:00 +0530
committerLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-06-05 08:03:31 +0530
commit368471dba24587415cae04ca33879404fb8639a5 (patch)
treeb216754eed7d6f478ceefea9ef3c0ab5698581d4 /src/api
parentUpgraded electron to '13.1.1'. (diff)
downloadferdium-app-368471dba24587415cae04ca33879404fb8639a5.tar.gz
ferdium-app-368471dba24587415cae04ca33879404fb8639a5.tar.zst
ferdium-app-368471dba24587415cae04ca33879404fb8639a5.zip
Reused commonly defined method for 'apiBase'
Diffstat (limited to 'src/api')
-rw-r--r--src/api/apiBase.js3
-rw-r--r--src/api/server/ServerApi.js4
2 files changed, 4 insertions, 3 deletions
diff --git a/src/api/apiBase.js b/src/api/apiBase.js
index 85dd0f3df..842c85e56 100644
--- a/src/api/apiBase.js
+++ b/src/api/apiBase.js
@@ -18,7 +18,8 @@ const apiBase = (withVersion = true) => {
18 || !window.ferdi.stores.settings.all.app.server) { 18 || !window.ferdi.stores.settings.all.app.server) {
19 // Stores have not yet been loaded - return SERVER_NOT_LOADED to force a retry when stores are loaded 19 // Stores have not yet been loaded - return SERVER_NOT_LOADED to force a retry when stores are loaded
20 return SERVER_NOT_LOADED; 20 return SERVER_NOT_LOADED;
21 } if (window.ferdi.stores.settings.all.app.server === LOCAL_SERVER) { 21 }
22 if (window.ferdi.stores.settings.all.app.server === LOCAL_SERVER) {
22 // Use URL for local server 23 // Use URL for local server
23 url = `http://127.0.0.1:${window.ferdi.stores.requests.localServerPort}`; 24 url = `http://127.0.0.1:${window.ferdi.stores.requests.localServerPort}`;
24 } else { 25 } else {
diff --git a/src/api/server/ServerApi.js b/src/api/server/ServerApi.js
index 5fd5268ce..5365f9dbe 100644
--- a/src/api/server/ServerApi.js
+++ b/src/api/server/ServerApi.js
@@ -457,7 +457,7 @@ export default class ServerApi {
457 457
458 // News 458 // News
459 async getLatestNews() { 459 async getLatestNews() {
460 const url = `https://api.getferdi.com/v1/news?platform=${os.platform()}&arch=${os.arch()}&version=${app.getVersion()}`; 460 const url = `${apiBase(true)}/news?platform=${os.platform()}&arch=${os.arch()}&version=${app.getVersion()}`;
461 const request = await sendAuthRequest(url); 461 const request = await sendAuthRequest(url);
462 if (!request.ok) throw request; 462 if (!request.ok) throw request;
463 const data = await request.json(); 463 const data = await request.json();
@@ -467,7 +467,7 @@ export default class ServerApi {
467 } 467 }
468 468
469 async hideNews(id) { 469 async hideNews(id) {
470 const request = await sendAuthRequest(`https://api.getferdi.com/v1/news/${id}/read`); 470 const request = await sendAuthRequest(`${apiBase(true)}/news/${id}/read`);
471 if (!request.ok) throw request; 471 if (!request.ok) throw request;
472 debug('ServerApi::hideNews resolves', id); 472 debug('ServerApi::hideNews resolves', id);
473 } 473 }