Skip to content

Commit b89f860

Browse files
committed
refactor: update restResource function to use params instead of request
1 parent 145c6c8 commit b89f860

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

projects/resource/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
"bugs": {
3232
"url": "https://github.com/angular-experts-io/resource/issues"
3333
}
34-
}
34+
}

projects/resource/src/lib/resource/resource.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ describe('Rest Resource', () => {
11081108
expect(consoleDebugSpy).toHaveBeenCalledWith(
11091109
'[@angular-experts/resource]',
11101110
'Read (Angular resource)',
1111-
{ fullUrl: 'some/api', request: '' },
1111+
{ fullUrl: 'some/api', params: '' },
11121112
);
11131113
});
11141114

projects/resource/src/lib/resource/resource.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
import { behaviorToOperator, streamify } from './resource.util';
1919

2020
// eslint-disable-next-line @typescript-eslint/no-explicit-any
21-
export function restResource<T, ID, E extends Error>(
21+
export function restResource<T, ID, E extends Error = Error>(
2222
apiEndpoint: string,
2323
options: RestResourceOptions<T, ID> = {},
2424
) {
@@ -34,10 +34,10 @@ export function restResource<T, ID, E extends Error>(
3434
const errorRemove = signal<E | undefined>(undefined);
3535

3636
const resource = rxResource({
37-
request: () => options.params?.() ?? '',
38-
loader: ({ request }) => {
39-
const fullUrl = `${apiEndpoint}${request}`;
40-
verbose('Read (Angular resource)', { request, fullUrl });
37+
params: () => options.params?.() ?? '',
38+
stream: ({ params }) => {
39+
const fullUrl = `${apiEndpoint}${params}`;
40+
verbose('Read (Angular resource)', { params, fullUrl });
4141
return http.get<T[]>(fullUrl);
4242
},
4343
});

0 commit comments

Comments
 (0)