Skip to content

Commit

Permalink
update more
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 26, 2023
1 parent 447ff00 commit 0eb629b
Show file tree
Hide file tree
Showing 4 changed files with 2,977 additions and 1,289 deletions.
19 changes: 6 additions & 13 deletions examples/query-string.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { ofetch } from "ofetch";

async function main() {
const response = await ofetch(
"https://api.github.com/repos/unjs/ofetch/tags",
{
query: {
per_page: 2,
},
}
); // Be careful, we use the GitHub API directly.
const response = await ofetch("https://api.github.com/repos/unjs/ofetch/tags", {
query: {
per_page: 2,
},
}); // Be careful, we use the GitHub API directly.

console.log(response);
}

main().catch(console.error);
console.log(response);
2 changes: 2 additions & 0 deletions examples/type-safety.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @ts-ignore
import { ofetch } from "ofetch";

interface Repo {
Expand All @@ -16,4 +17,5 @@ async function main() {
console.log(`The repo ${repo.name} has ${repo.stars} stars.`); // The repo object is now strongly typed.
}

// eslint-disable-next-line unicorn/prefer-top-level-await
main().catch(console.error);
12 changes: 12 additions & 0 deletions playground/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { $fetch } from "..";

async function main() {
await $fetch("http://google.com/404");
}

// eslint-disable-next-line unicorn/prefer-top-level-await
main().catch((error) => {
console.error(error);
// eslint-disable-next-line unicorn/no-process-exit
process.exit(1);
});
Loading

0 comments on commit 0eb629b

Please sign in to comment.