Skip to content

Commit

Permalink
add url function if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
SchroterQuentin committed Mar 27, 2024
1 parent 9256b90 commit 631eb84
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Bones.UI/core/serviceFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ export class ServiceFactory<TDetailsDTO, TDetails> {
return { get };
}

addFetch(url: string): { fetch: () => Promise<TDetails> } {
addFetch(url: string | (() => string)): { fetch: () => Promise<TDetails> } {

const fetch = async () => {
const response = await ServiceFactory.http.get(url);
const realUrl = typeof url === "string" ? url : url();

const response = await ServiceFactory.http.get(realUrl);
const dto: TDetailsDTO = response.data;

const result = new this.EntityDetails(dto);
Expand Down

0 comments on commit 631eb84

Please sign in to comment.