Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetcher function TS example #386

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pages/docs/getting-started.en-US.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ For normal RESTful APIs with JSON data, first you need to create a `fetcher` fun
const fetcher = (...args) => fetch(...args).then(res => res.json())
```

Or with TypeScript:

```jsx
const fetcher = (...args: Parameters<typeof fetch>) => fetch(...args).then((res) => res.json());
```

<Callout emoji="💡">
If you want to use GraphQL API or libs like Axios, you can create your own fetcher function.
Check <Link href="/docs/data-fetching"><a href="/docs/data-fetching">here</a></Link> for more examples.
Expand Down
6 changes: 6 additions & 0 deletions pages/docs/getting-started.es-ES.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ del `fetch` nativo:
const fetcher = (...args) => fetch(...args).then(res => res.json())
```

Or with TypeScript:

```jsx
const fetcher = (...args: Parameters<typeof fetch>) => fetch(...args).then((res) => res.json());
```

<Callout emoji="💡">
Si tu quieres usar API GraphQL o librerías como Axios, puedes crear tu propia función fetcher. Consulta
<Link href="/docs/data-fetching"><a href="/docs/data-fetching">aqui</a></Link> para ver más ejemplos.
Expand Down
6 changes: 6 additions & 0 deletions pages/docs/getting-started.ja.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ JSON データを使用する通常の RESTful API の場合、まずネイテ
const fetcher = (...args) => fetch(...args).then(res => res.json())
```

Or with TypeScript:

```jsx
const fetcher = (...args: Parameters<typeof fetch>) => fetch(...args).then((res) => res.json());
```

<Callout emoji="💡">
もし GraphQL API または Axios のようなライブラリを使いたい場合は、独自のフェッチャー関数を作ることができます。
その他の例は<Link href="/docs/data-fetching"><a href="/docs/data-fetching">こちら</a></Link>をご覧ください。
Expand Down
6 changes: 6 additions & 0 deletions pages/docs/getting-started.ko.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ JSON 데이터를 사용하는 일반적인 RESTful API라면 먼저 네이티
const fetcher = (...args) => fetch(...args).then(res => res.json())
```

Or with TypeScript:

```jsx
const fetcher = (...args: Parameters<typeof fetch>) => fetch(...args).then((res) => res.json());
```

<Callout emoji="💡">
GraphQL API 또는 Axios와 같은 라이브러리를 사용하려면 여러분만의 fetcher 함수를 생성하면 됩니다.
<Link href="/docs/data-fetching"><a href="/docs/data-fetching">여기</a></Link>에서 더 많은 예시를 확인하세요.
Expand Down
6 changes: 6 additions & 0 deletions pages/docs/getting-started.pt-BR.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Para APIs RESTful normais com dados JSON, primeiro você precisa criar uma funç
const fetcher = (...args) => fetch(...args).then(res => res.json())
```

Or with TypeScript:

```jsx
const fetcher = (...args: Parameters<typeof fetch>) => fetch(...args).then((res) => res.json());
```

<Callout emoji="💡">
Se você quer usar APIs GraphQL ou outras bibliotecas como Axios, você pode criar sua própria função fetcher.
Veja <Link href="/docs/data-fetching"><a href="/docs/data-fetching">aqui</a></Link> para mais exemplos.
Expand Down
6 changes: 6 additions & 0 deletions pages/docs/getting-started.ru.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ npm install swr
const fetcher = (...args) => fetch(...args).then(res => res.json())
```

Or with TypeScript:

```jsx
const fetcher = (...args: Parameters<typeof fetch>) => fetch(...args).then((res) => res.json());
```

<Callout emoji="💡">
Если вы хотите использовать GraphQL API или библиотеки, такие как Axios, вы можете создать свою
собственную fetcher-функцию.
Expand Down
6 changes: 6 additions & 0 deletions pages/docs/getting-started.zh-CN.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ npm install swr
const fetcher = (...args) => fetch(...args).then((res) => res.json())
```

Or with TypeScript:

```jsx
const fetcher = (...args: Parameters<typeof fetch>) => fetch(...args).then((res) => res.json());
```

<Callout emoji="💡">
如果要使用 GraphQL API 或类似 Axios 的库,可以自己创建 fetcher 函数。 点击 <Link href="/docs/data-fetching"><a href="/docs/data-fetching">这里</a></Link> 查看更多示例。
</Callout>
Expand Down