Skip to content

Commit

Permalink
Merge pull request #37 from geoblocks/add-replacer
Browse files Browse the repository at this point in the history
Add replacer to requestReport to support custom replacer to the client.
  • Loading branch information
ismailsunni authored Aug 15, 2024
2 parents 918de2b + 46553b3 commit e0dd18a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,17 @@ export async function cancelPrint(mfpBaseUrl: string, ref: string): Promise<MFPC
return {status: response.status};
}

export async function requestReport(mfpBaseUrl: string, spec: MFPSpec): Promise<MFPReportResponse> {
export async function requestReport(
mfpBaseUrl: string,
spec: MFPSpec,
replacer?: (key: string, value: any) => any | (string | number)[],
): Promise<MFPReportResponse> {
const report = await fetch(`${mfpBaseUrl}/report.${spec.format}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(spec),
body: JSON.stringify(spec, replacer),
});
return await report.json();
}
Expand Down

0 comments on commit e0dd18a

Please sign in to comment.