-

+
+
{/if}
diff --git a/src/routes/market-news/general/+page.ts b/src/routes/market-news/general/+page.ts
index 4ba0a84f..3036d319 100644
--- a/src/routes/market-news/general/+page.ts
+++ b/src/routes/market-news/general/+page.ts
@@ -1,24 +1,8 @@
-import { userRegion, getCache, setCache } from '$lib/store';
-
-
-const usRegion = ['cle1','iad1','pdx1','sfo1'];
-
-let apiURL;
-let apiKey = import.meta.env.VITE_STOCKNEAR_API_KEY;
-
-
-userRegion.subscribe(value => {
-
- if (usRegion.includes(value)) {
- apiURL = import.meta.env.VITE_USEAST_API_URL;
- } else {
- apiURL = import.meta.env.VITE_EU_API_URL;
- }
-});
+import { getCache, setCache } from '$lib/store';
-export const load = async () => {
+export const load = async ({parent}) => {
const getGeneralNews = async () => {
let output;
@@ -27,16 +11,16 @@ export const load = async () => {
if (cachedData) {
output = cachedData;
} else {
- const postData = {
- ticker: ''
- };
+ const { apiURL, apiKey } = await parent();
+ const postData = {'newsType': 'general-news'}
// make the POST request to the endpoint
- const response = await fetch(apiURL + '/general-news', {
- method: 'GET',
+ const response = await fetch(apiURL + '/market-news', {
+ method: 'POST',
headers: {
"Content-Type": "application/json", "X-API-KEY": apiKey
},
+ body: JSON.stringify(postData)
});
output = await response.json();
diff --git a/src/routes/market-news/crypto/+page.svelte b/src/routes/market-news/press-release/+page.svelte
similarity index 74%
rename from src/routes/market-news/crypto/+page.svelte
rename to src/routes/market-news/press-release/+page.svelte
index 1004f831..b2972f39 100644
--- a/src/routes/market-news/crypto/+page.svelte
+++ b/src/routes/market-news/press-release/+page.svelte
@@ -6,7 +6,7 @@ import { formatDate } from '$lib/utils';
export let data;
-let rawData = data?.getCryptoNews;
+let rawData = data?.getPressRelease;
let news = rawData.slice(0,5) ?? [];
@@ -82,29 +82,20 @@ function checkIfYoutubeVideo(link) {
{#if news.length !== 0}
{#each news as item}
-
- {#if videoId = checkIfYoutubeVideo(item.url)}
-
- {:else}
-
-
-

-
-
- {/if}
+
+
+
+
+

+
+
-
+
{item?.title?.length > 120 ? item?.title?.slice(0,120) +'...' : item?.title}
diff --git a/src/routes/market-news/press-release/+page.ts b/src/routes/market-news/press-release/+page.ts
new file mode 100644
index 00000000..1c4478f0
--- /dev/null
+++ b/src/routes/market-news/press-release/+page.ts
@@ -0,0 +1,39 @@
+import { getCache, setCache } from '$lib/store';
+
+
+
+export const load = async ({parent}) => {
+ const getPressRelease = async () => {
+ let output;
+
+ // Get cached data for the specific tickerID
+ const cachedData = getCache('', 'getPressRelease');
+ if (cachedData) {
+ output = cachedData;
+ } else {
+ const { apiURL, apiKey } = await parent();
+ const postData = {'newsType': 'press-releases'}
+
+ // make the POST request to the endpoint
+ const response = await fetch(apiURL + '/market-news', {
+ method: 'POST',
+ headers: {
+ "Content-Type": "application/json", "X-API-KEY": apiKey
+ },
+ body: JSON.stringify(postData)
+ });
+
+ output = await response.json();
+
+ // Cache the data for this specific tickerID with a specific name 'getPressRelease'
+ setCache('', output, 'getPressRelease');
+ }
+
+ return output;
+ };
+
+ // Make sure to return a promise
+ return {
+ getPressRelease: await getPressRelease()
+ };
+};
\ No newline at end of file