Skip to content

Commit

Permalink
refactor: modify to use uncached api and remove unused styles
Browse files Browse the repository at this point in the history
  • Loading branch information
woowapark committed Aug 24, 2023
1 parent 7699998 commit cf16a0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
10 changes: 3 additions & 7 deletions src/apis/gifAPIService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GifsResult, GiphyFetch, SearchOptions, TrendingOptions } from '@giphy/js-fetch-api';
import { GifsResult, GiphyFetch, SearchOptions } from '@giphy/js-fetch-api';
import { IGif } from '@giphy/js-types';

import { GifImageModel } from '../models/image/gifImage';
Expand All @@ -7,6 +7,7 @@ const apiKey = process.env.GIPHY_API_KEY || '';
const gf = new GiphyFetch(apiKey);

const DEFAULT_FETCH_COUNT = 16;
const TRENDING_GIF_API = `https://api.giphy.com/v1/gifs/trending?api_key=${process.env.GIPHY_API_KEY}&limit=${DEFAULT_FETCH_COUNT}&rating=g`;

function convertResponseToModel(gifList: IGif[]): GifImageModel[] {
return gifList.map((gif) => {
Expand All @@ -27,13 +28,8 @@ export const gifAPIService = {
* @ref https://developers.giphy.com/docs/api/endpoint#!/gifs/trending
*/
getTrending: async function (): Promise<GifImageModel[]> {
const trendingOptions: TrendingOptions = {
limit: DEFAULT_FETCH_COUNT,
rating: 'g'
};

try {
const gifs: GifsResult = await gf.trending(trendingOptions);
const gifs: GifsResult = await fetch(TRENDING_GIF_API).then((res) => res.json());
return convertResponseToModel(gifs.data);
} catch (e) {
return [];
Expand Down
16 changes: 0 additions & 16 deletions src/components/NavBar/NavBar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,3 @@
rgba(233, 97, 195, 0.77) 57.81%
);
}

/* @media all and (max-width:424px) {
.header {
padding: 0 1rem;
height: 4.5rem;
}
.logo {
font-size: 1.5rem;
}
.searchPageButton {
font-size: 1.5rem;
height: 2.5rem;
}
} */

0 comments on commit cf16a0c

Please sign in to comment.