Skip to content

Commit 5a14d42

Browse files
committed
fix: use ofetch instead of $fetch
1 parent 2d0c85a commit 5a14d42

7 files changed

+14
-14
lines changed

examples/body.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { $fetch } from "ofetch";
1+
import { ofetch } from "ofetch";
22

33
async function main() {
4-
const response = await $fetch<string>("https://api.github.com/markdown", {
4+
const response = await ofetch<string>("https://api.github.com/markdown", {
55
method: "POST",
66
// To provide a body, we need to use the `body` option and just use an object.
77
body: {

examples/error-handling.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { $fetch } from "ofetch";
1+
import { ofetch } from "ofetch";
22

33
async function main() {
44
try {
5-
await $fetch("https://api.github.com", {
5+
await ofetch("https://api.github.com", {
66
method: "POST",
77
});
88
} catch (error) {

examples/first-request.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { $fetch } from "ofetch";
1+
import { ofetch } from "ofetch";
22

33
async function main() {
4-
const data = await $fetch("https://ungh.cc/repos/unjs/ofetch");
4+
const data = await ofetch("https://ungh.cc/repos/unjs/ofetch");
55

66
console.log(data);
77
}

examples/headers.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { $fetch } from "ofetch";
1+
import { ofetch } from "ofetch";
22

33
async function main() {
4-
const response = await $fetch("https://api.github.com/gists", {
4+
const response = await ofetch("https://api.github.com/gists", {
55
method: "POST",
66
headers: {
77
Authorization: `token ${process.env.GH_TOKEN}`,

examples/methods.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { $fetch } from "ofetch";
1+
import { ofetch } from "ofetch";
22

33
async function main() {
4-
const response = await $fetch("https://api.github.com/gists", {
4+
const response = await ofetch("https://api.github.com/gists", {
55
method: "POST",
66
}); // Be careful, we use the GitHub API directly.
77

examples/query-string.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { $fetch } from "ofetch";
1+
import { ofetch } from "ofetch";
22

33
async function main() {
4-
const response = await $fetch(
4+
const response = await ofetch(
55
"https://api.github.com/repos/unjs/ofetch/tags",
66
{
77
query: {

examples/type-safety.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { $fetch } from "ofetch";
1+
import { ofetch } from "ofetch";
22

33
interface Repo {
44
id: number;
@@ -9,7 +9,7 @@ interface Repo {
99
}
1010

1111
async function main() {
12-
const { repo } = await $fetch<{ repo: Repo }>(
12+
const { repo } = await ofetch<{ repo: Repo }>(
1313
"https://ungh.cc/repos/unjs/ofetch"
1414
);
1515

0 commit comments

Comments
 (0)