|
@@ -64,6 +64,23 @@ class ApiRequestService {
|
|
|
return await this.request(HTTP_METHOD.PUT, url, body, query, headers)
|
|
return await this.request(HTTP_METHOD.PUT, url, body, query, headers)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Send a PUT request
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param url
|
|
|
|
|
+ * @param body
|
|
|
|
|
+ * @param query
|
|
|
|
|
+ * @param headers
|
|
|
|
|
+ */
|
|
|
|
|
+ public async patch(
|
|
|
|
|
+ url: string,
|
|
|
|
|
+ body: string | AnyJson | null = null,
|
|
|
|
|
+ query: AssociativeArray | null = null,
|
|
|
|
|
+ headers: AssociativeArray | null = null,
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return await this.request(HTTP_METHOD.PATCH, url, body, query, headers)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Send a DELETE request
|
|
* Send a DELETE request
|
|
|
*
|
|
*
|
|
@@ -100,11 +117,19 @@ class ApiRequestService {
|
|
|
if (query) {
|
|
if (query) {
|
|
|
config.query = query
|
|
config.query = query
|
|
|
}
|
|
}
|
|
|
- if (method === HTTP_METHOD.POST || method === HTTP_METHOD.PUT) {
|
|
|
|
|
|
|
+
|
|
|
|
|
+ config.headers = headers ? { ...headers } : {}
|
|
|
|
|
+
|
|
|
|
|
+ config.headers['Accept'] = 'application/ld+json'
|
|
|
|
|
+ config.headers['Content-Type'] = 'application/ld+json'
|
|
|
|
|
+
|
|
|
|
|
+ if (method === HTTP_METHOD.POST || method === HTTP_METHOD.PUT || method === HTTP_METHOD.PATCH) {
|
|
|
config.body = body
|
|
config.body = body
|
|
|
}
|
|
}
|
|
|
- if (headers) {
|
|
|
|
|
- config.headers = headers
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (method === HTTP_METHOD.PATCH) {
|
|
|
|
|
+ // config.headers['Accept'] = 'application/merge-patch+json'
|
|
|
|
|
+ config.headers['Content-Type'] = 'application/merge-patch+json'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// @ts-expect-error TODO: solve the type mismatch
|
|
// @ts-expect-error TODO: solve the type mismatch
|