Computer Programming/Next
2023. 8. 1.
Next.js - fetch๋ฅผ ์ด์ฉํ SSG, ISR, SSR, CSR ๊ตฌํ ์ต์
1. SSG - ๋น๋๊ธฐ ๋ฐ์ดํฐ fetching data / products.json์ ๋ฐ์ดํฐ๊ฐ ์๋ค๊ณ ๊ฐ์ ํ๊ณ [ { "id": "1", "name": "์ฒญ๋ฐ์ง", "price": "10000" }, { "id": "2", "name": "ํฐ์
์ธ ", "price": "13000" }, ...objects ] api ํด๋์ products.ts ๋ชจ๋์ ๋ง๋ค์ด ๋ฐ์ดํฐ๋ฅผ ๊ฐ์ ธ์จ๋ค. import path from "path"; import { promises as fs } from "fs"; export type Product = { id: string; name: string; price: string; }; export async function getProducts(): Promise { const fil..