File tree 9 files changed +64
-56
lines changed
9 files changed +64
-56
lines changed Original file line number Diff line number Diff line change 1
1
{
2
- "extends": ["eslint-config-unjs"],
2
+ "extends": [
3
+ "eslint-config-unjs"
4
+ ],
3
5
"rules": {
4
6
"no-undef": 0,
5
7
"unicorn/consistent-destructuring": 0,
6
- "unicorn/no-await-expression-member": 0
8
+ "unicorn/no-await-expression-member": 0,
9
+ "unicorn/prefer-top-level-await": 0
7
10
}
8
11
}
Original file line number Diff line number Diff line change 1
- import { $fetch } from ' ofetch'
1
+ import { $fetch } from " ofetch" ;
2
2
3
3
async function main ( ) {
4
- const response = await $fetch < string > ( ' https://api.github.com/markdown' , {
5
- method : ' POST' ,
4
+ const response = await $fetch < string > ( " https://api.github.com/markdown" , {
5
+ method : " POST" ,
6
6
// To provide a body, we need to use the `body` option and just use an object.
7
7
body : {
8
- text : ' UnJS is **awesome**!\n\nCheck out their [website](https://unjs.io).' ,
8
+ text : " UnJS is **awesome**!\n\nCheck out their [website](https://unjs.io)." ,
9
9
} ,
10
- } ) // Be careful, we use the GitHub API.
10
+ } ) ; // Be careful, we use the GitHub API.
11
11
12
- console . log ( response )
12
+ console . log ( response ) ;
13
13
}
14
14
15
- main ( ) . catch ( console . error )
15
+ main ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1
- import { $fetch } from "ofetch"
1
+ import { $fetch } from "ofetch" ;
2
2
3
3
async function main ( ) {
4
4
try {
5
5
await $fetch ( "https://api.github.com" , {
6
- method : ' POST'
7
- } )
6
+ method : " POST" ,
7
+ } ) ;
8
8
} catch ( error ) {
9
- console . log ( error . data ) // This allow us to get the error body.
9
+ console . log ( error . data ) ; // This allow us to get the error body.
10
10
}
11
11
}
12
12
13
- main ( ) . catch ( console . error )
13
+ main ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1
- import { $fetch } from "ofetch"
1
+ import { $fetch } from "ofetch" ;
2
2
3
3
async function main ( ) {
4
- const data = await $fetch ( "https://ungh.cc/repos/unjs/ofetch" )
4
+ const data = await $fetch ( "https://ungh.cc/repos/unjs/ofetch" ) ;
5
5
6
- console . log ( data )
6
+ console . log ( data ) ;
7
7
}
8
8
9
- main ( ) . catch ( console . error )
9
+ main ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1
- import { $fetch } from ' ofetch'
1
+ import { $fetch } from " ofetch" ;
2
2
3
3
async function main ( ) {
4
- const response = await $fetch ( ' https://api.github.com/gists' , {
5
- method : ' POST' ,
4
+ const response = await $fetch ( " https://api.github.com/gists" , {
5
+ method : " POST" ,
6
6
headers : {
7
7
Authorization : `token ${ process . env . GH_TOKEN } ` ,
8
8
} ,
9
9
body : {
10
- description : ' This is a gist created by ofetch.' ,
10
+ description : " This is a gist created by ofetch." ,
11
11
public : true ,
12
12
files : {
13
- ' unjs.txt' : {
14
- content : ' UnJS is awesome!' ,
15
- }
16
- }
17
- }
18
- } ) // Be careful, we use the GitHub API directly.
13
+ " unjs.txt" : {
14
+ content : " UnJS is awesome!" ,
15
+ } ,
16
+ } ,
17
+ } ,
18
+ } ) ; // Be careful, we use the GitHub API directly.
19
19
20
- console . log ( response . url )
20
+ console . log ( response . url ) ;
21
21
}
22
22
23
- main ( ) . catch ( console . error )
23
+ main ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1
- import { $fetch } from ' ofetch'
1
+ import { $fetch } from " ofetch" ;
2
2
3
3
async function main ( ) {
4
- const response = await $fetch ( ' https://api.github.com/gists' , {
5
- method : ' POST' ,
6
- } ) // Be careful, we use the GitHub API directly.
4
+ const response = await $fetch ( " https://api.github.com/gists" , {
5
+ method : " POST" ,
6
+ } ) ; // Be careful, we use the GitHub API directly.
7
7
8
- console . log ( response )
8
+ console . log ( response ) ;
9
9
}
10
10
11
- main ( ) . catch ( console . error )
11
+ main ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1
- import { $fetch } from "ofetch"
1
+ import { $fetch } from "ofetch" ;
2
2
3
3
async function main ( ) {
4
- const response = await $fetch ( 'https://api.github.com/repos/unjs/ofetch/tags' , {
5
- query : {
6
- per_page : 2 ,
7
- } ,
8
- } ) // Be careful, we use the GitHub API directly.
4
+ const response = await $fetch (
5
+ "https://api.github.com/repos/unjs/ofetch/tags" ,
6
+ {
7
+ query : {
8
+ per_page : 2 ,
9
+ } ,
10
+ }
11
+ ) ; // Be careful, we use the GitHub API directly.
9
12
10
- console . log ( response )
13
+ console . log ( response ) ;
11
14
}
12
15
13
- main ( ) . catch ( console . error )
16
+ main ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 1
- import { $fetch } from "ofetch"
1
+ import { $fetch } from "ofetch" ;
2
2
3
3
interface Repo {
4
- id : number
5
- name : string
6
- repo : string
7
- description : string
8
- stars : number
4
+ id : number ;
5
+ name : string ;
6
+ repo : string ;
7
+ description : string ;
8
+ stars : number ;
9
9
}
10
10
11
11
async function main ( ) {
12
- const { repo } = await $fetch < { repo : Repo } > ( "https://ungh.cc/repos/unjs/ofetch" )
12
+ const { repo } = await $fetch < { repo : Repo } > (
13
+ "https://ungh.cc/repos/unjs/ofetch"
14
+ ) ;
13
15
14
- console . log ( `The repo ${ repo . name } has ${ repo . stars } stars.` ) // The repo object is now strongly typed.
16
+ console . log ( `The repo ${ repo . name } has ${ repo . stars } stars.` ) ; // The repo object is now strongly typed.
15
17
}
16
18
17
- main ( ) . catch ( console . error )
19
+ main ( ) . catch ( console . error ) ;
Original file line number Diff line number Diff line change 62
62
"scripts" : {
63
63
"build" : " unbuild" ,
64
64
"dev" : " vitest" ,
65
- "lint" : " eslint --ext .ts . && prettier -c src test playground" ,
66
- "lint:fix" : " eslint --fix --ext .ts . && prettier -w src test playground" ,
65
+ "lint" : " eslint --ext .ts . && prettier -c src test playground examples " ,
66
+ "lint:fix" : " eslint --fix --ext .ts . && prettier -w src test playground examples " ,
67
67
"prepack" : " pnpm build" ,
68
68
"play" : " jiti playground/index.ts" ,
69
69
"release" : " pnpm test && changelogen --release && npm publish && git push --follow-tags" ,
92
92
"vitest" : " ^0.34.3"
93
93
},
94
94
"packageManager" :
" [email protected] "
95
- }
95
+ }
You can’t perform that action at this time.
0 commit comments