Skip to content

Commit

Permalink
fix: Daf-rest overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat authored and mirceanis committed Sep 7, 2020
1 parent 68c75ff commit 0d6c031
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/daf-rest/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ export class AgentRestClient implements IAgentPlugin {
}) {
this.url = options.url

const allMethods: Record<string, IAgentRESTMethod> = { ...supportedMethods, ...options.overrides }

for (const method of options.enabledMethods) {
if (supportedMethods[method]) {
if (allMethods[method]) {
this.methods[method] = async (args: any) => {
// TODO: handle GET
const res = await fetch(this.url + supportedMethods[method].path, {
const res = await fetch(this.url + allMethods[method].path, {
headers: { ...options.headers, 'Content-Type': 'application/json' },
method: supportedMethods[method].type,
method: allMethods[method].type,
body: JSON.stringify(args),
})
const json = await res.json()
Expand Down

0 comments on commit 0d6c031

Please sign in to comment.