esc-chula / intania-form

Intania Form is a form wrapper of NocoDB for internal uses in the Engineering Faculty of Chulalongkorn University.
1 stars 0 forks source link

Refactor Fetch #2

Open shalluv opened 2 months ago

shalluv commented 2 months ago

Seem like there are a lot of repetition of

const response = await fetch(
    `${process.env.NOCODB_BASE_URL}/api/v2/...`,
    {
      headers: {
        'xc-token': process.env.NOCODB_XC_TOKEN ?? '',
      },
      next: { revalidate: 60 },
    }
  )

Can we create a function fetcher or something to handle them? Additionally, please move functions inside this file to separate files since right now file name does not match function inside.

Also, if you want to use external lib, it's fine but please start a thread in discord first.

_Originally posted by @shalluv in https://github.com/esc-chula/intania-form/pull/1#discussion_r1733017186_

shalluv commented 2 months ago

Let's find a better way to handle requesting!