From 9ed8eeeac7b23b881bfd2debb25e1a0b33034365 Mon Sep 17 00:00:00 2001 From: Scott Nath Date: Thu, 19 Oct 2023 11:15:55 -0400 Subject: [PATCH] :bug: add no-cache so node does not cache --- src/devto/post/content.js | 8 ++++++-- src/devto/user/content.js | 8 ++++++-- src/github/repository/content.js | 5 ++++- src/github/user/content.js | 5 ++++- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/devto/post/content.js b/src/devto/post/content.js index 513f402..80474ff 100644 --- a/src/devto/post/content.js +++ b/src/devto/post/content.js @@ -28,7 +28,9 @@ import { getApiUrl } from '../helpers/index.js'; * @ignore */ export const fetchPost = async (id) => { - const response = await fetch(`${getApiUrl()}/articles/${id}`); + const response = await fetch(`${getApiUrl()}/articles/${id}`, { + cache: 'no-cache', + }); const repoJson = await response.json(); return repoJson; } @@ -40,7 +42,9 @@ export const fetchPost = async (id) => { * @ignore */ export const fetchUserPosts = async (username) => { - const articles = await fetch(`${getApiUrl()}/articles/latest?per_page=1000&username=${username?.toLowerCase()}`); + const articles = await fetch(`${getApiUrl()}/articles/latest?per_page=1000&username=${username?.toLowerCase()}`, { + cache: 'no-cache', + }); const articlesJson = await articles.json(); return articlesJson; } diff --git a/src/devto/user/content.js b/src/devto/user/content.js index 7ddee8a..74c82b6 100644 --- a/src/devto/user/content.js +++ b/src/devto/user/content.js @@ -43,9 +43,13 @@ const blankPng = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1 export const fetchUser = async (username, id) => { let response; if (!username && id) { - response = await fetch(`${getApiUrl()}/users/${id}`); + response = await fetch(`${getApiUrl()}/users/${id}`, { + cache: 'no-cache', + }); } else { - response = await fetch(`${getApiUrl()}/users/by_username?url=${username?.toLowerCase()}`); + response = await fetch(`${getApiUrl()}/users/by_username?url=${username?.toLowerCase()}`, { + cache: 'no-cache', + }); } const userJson = await response.json(); return userJson; diff --git a/src/github/repository/content.js b/src/github/repository/content.js index 99d6ad4..ebf61ab 100644 --- a/src/github/repository/content.js +++ b/src/github/repository/content.js @@ -26,7 +26,10 @@ const githubApi = 'https://api.github.com'; * @ignore */ export const fetchRepo = async (full_name) => { - const response = await fetch(`${githubApi}/repos/${full_name}`); + const options = { + cache: 'no-cache', + }; + const response = await fetch(`${githubApi}/repos/${full_name}`, options); const repoJson = await response.json(); return repoJson; } diff --git a/src/github/user/content.js b/src/github/user/content.js index 87b2416..445212c 100644 --- a/src/github/user/content.js +++ b/src/github/user/content.js @@ -36,7 +36,10 @@ const blankPng = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1 * @ignore */ export const fetchUser = async (username) => { - const response = await fetch(`${githubApi}/users/${username}`); + const options = { + cache: 'no-cache', + }; + const response = await fetch(`${githubApi}/users/${username}`, options); const userJson = await response.json(); return userJson; }