File tree Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @yme/api" ,
3
- "description" : " Simply create some standalone functions" ,
3
+ "description" : " Simply create some request functions" ,
4
4
"version" : " 0.0.0-development" ,
5
5
"type" : " module" ,
6
6
"sideEffects" : false ,
Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ npm install @yme/api
30
30
Use ` ApiClient ` with ` fetch ` (Action first)
31
31
32
32
``` ts
33
- import { ApiClient , replacePathParams } from " @yme/api/client" ;
33
+ import { createClient , replacePathParams } from " @yme/api/client" ;
34
34
import { logger } from " @yme/api/middleware" ;
35
35
36
- const api = new ApiClient ({
36
+ const api = createClient ({
37
37
action : async ({ req }) => {
38
38
// make http request and return data
39
39
const response = await fetch (req .url , {
@@ -80,8 +80,8 @@ const newUserId = await createUser(
80
80
Use ` NextAction ` for Next.js server action (Action last)
81
81
82
82
``` ts
83
- import { NextAction } from " @yme/api/next" ;
84
- const api = new NextAction ({
83
+ import { createAction } from " @yme/api/next" ;
84
+ const api = createAction ({
85
85
middlewares: [],
86
86
// throwing an error will make the server return status 500
87
87
// we can handle it in the error handler. e.g. returns a fallback data with error message
Original file line number Diff line number Diff line change @@ -30,10 +30,10 @@ npm install @yme/api
30
30
Use ` ApiClient ` with ` fetch ` (Action first)
31
31
32
32
``` ts
33
- import { ApiClient , replacePathParams } from " @yme/api/client" ;
33
+ import { createClient , replacePathParams } from " @yme/api/client" ;
34
34
import { logger } from " @yme/api/middleware" ;
35
35
36
- const api = new ApiClient ({
36
+ const api = createClient ({
37
37
action : async ({ req }) => {
38
38
// make http request and return data
39
39
const response = await fetch (req .url , {
@@ -80,8 +80,8 @@ const newUserId = await createUser(
80
80
Use ` NextAction ` for Next.js server action (Action last)
81
81
82
82
``` ts
83
- import { NextAction } from " @yme/api/next" ;
84
- const api = new NextAction ({
83
+ import { createAction } from " @yme/api/next" ;
84
+ const api = createAction ({
85
85
middlewares: [],
86
86
// throwing an error will make the server return status 500
87
87
// we can handle it in the error handler. e.g. returns a fallback data with error message
You can’t perform that action at this time.
0 commit comments