API
Getting Started
How to use

How to use the API (With Next JS)

API URL: https://api.sulio.kro.kr/api/information (opens in a new tab)

Step 1

Install NodeJs

Step 2

Open cmd and type "“"npx create-next-app@latest" to install

Step 3

async function getData() {
  try {
    const res = await fetch("https://api.sulio.kro.kr/api/information", {
      next: {
        revalidate: 100
      }
    })
 
    if (!res.ok) {
      throw new Error("Failed to fetch data")
    }
    
    return res.json()
  } catch (err) {
    console.log("API connection failed")
  }
}
 
export default async function Stats() {
  const data = await getData()
  const [information] = await Promise.all([data])
  
  return (
    <>
      {!data ? "Failed to load API" : information.data.name}
      {!data ? "Failed to load API" : information.data.version}
      {!data ? "Failed to load API" : information.data.develop_period}
      {!data ? "Failed to load API" : information.data.last_update}
      {!data ? "Failed to load API" : information.data.developer}
    </>
  )
}

Step 4

Run npm run dev