From 07383b206437b58860f26313be20895c73b9c7cf Mon Sep 17 00:00:00 2001 From: Maurits Lourens Date: Mon, 30 Aug 2021 22:55:12 +0200 Subject: [PATCH] add patch method to the rest api interface --- packages/server/src/integrations/rest.ts | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/server/src/integrations/rest.ts b/packages/server/src/integrations/rest.ts index c55e991980..d6cf71e324 100644 --- a/packages/server/src/integrations/rest.ts +++ b/packages/server/src/integrations/rest.ts @@ -89,6 +89,26 @@ module RestModule { }, }, }, + patch: { + displayName: "PATCH", + readable: true, + type: QueryTypes.FIELDS, + urlDisplay: true, + fields: { + path: { + type: DatasourceFieldTypes.STRING, + }, + queryString: { + type: DatasourceFieldTypes.STRING, + }, + headers: { + type: DatasourceFieldTypes.OBJECT, + }, + requestBody: { + type: DatasourceFieldTypes.JSON, + }, + }, + }, delete: { displayName: "DELETE", type: QueryTypes.FIELDS, @@ -175,6 +195,21 @@ module RestModule { return await this.parseResponse(response) } + async patch({ path = "", queryString = "", headers = {}, json = {} }) { + this.headers = { + ...this.config.defaultHeaders, + ...headers, + } + + const response = await fetch(this.config.url + path + queryString, { + method: "PATCH", + headers: this.headers, + body: JSON.stringify(json), + }) + + return await this.parseResponse(response) + } + async delete({ path = "", queryString = "", headers = {} }) { this.headers = { ...this.config.defaultHeaders,