@@ -12,16 +12,24 @@ let clientGetUsersRetries: number | undefined;
1212/**
1313 * Adds user-worker.
1414 */
15- export const addUser : ClientFunction < [ UserWorker , number ?] , Promise < object > > = createClientFunction (
16- ( user : UserWorker , delay ?: number ) =>
17- fetch ( `https://reqres.in/api/users${ delay !== undefined ? `?delay=${ delay } ` : '' } ` , {
15+ export const addUser : ClientFunction <
16+ [ Readonly < { delay ?: number ; user : UserWorker } > ] ,
17+ Promise < object >
18+ > = createClientFunction (
19+ ( { delay, user} ) =>
20+ fetch ( `https://dummyjson.com/users/add${ delay !== undefined ? `?delay=${ delay } ` : '' } ` , {
1821 body : JSON . stringify ( user ) ,
19- headers : {
20- 'Content-Type' : 'application/json; charset=UTF-8' ,
21- ...( delay !== undefined && delay > 0 ? { 'x-api-key' : 'reqres-free-v1' } : undefined ) ,
22- } ,
22+ headers : { 'Content-Type' : 'application/json; charset=UTF-8' } ,
2323 method : 'POST' ,
24- } ) ,
24+ } )
25+ . then ( ( res ) => res . json ( ) )
26+ . then ( ( result : UserWorker ) => {
27+ // eslint-disable-next-line no-console
28+ console . log ( 'addUser return' , result ) ;
29+
30+ return result ;
31+ } ) ,
32+
2533 { name : 'addUser' , timeout : 3_000 } ,
2634) ;
2735
@@ -36,7 +44,7 @@ export const getUsers = ({delay = 0, retries = 0}: GetUsersOptions = {}): Promis
3644
3745 clientGetUsers = createClientFunction (
3846 ( clientDelay : number ) =>
39- fetch ( `https://reqres.in/api /users?delay=${ clientDelay } ` , { method : 'GET' } ) . then (
47+ fetch ( `https://dummyjson.com /users?delay=${ clientDelay } ` , { method : 'GET' } ) . then (
4048 ( res ) => res . json ( ) as unknown ,
4149 ) ,
4250 { name : 'getUsers' , retries, timeout : 6_000 } ,
0 commit comments