Add updateResource method to HttpHypermediaClient
authorFrank Bessou <frank.bessou@logilab.fr>
Fri, 28 Apr 2017 16:42:00 +0200
changeset 162 1960d7fa8edf
parent 161 b26c54547826
child 163 3fa4f698fb32
Add updateResource method to HttpHypermediaClient
src/Api.js
src/services/hypermedia.js
--- a/src/Api.js	Fri Apr 28 16:08:02 2017 +0200
+++ b/src/Api.js	Fri Apr 28 16:42:00 2017 +0200
@@ -91,14 +91,7 @@
 
     updateEntity(etype, eid, attributes) {
         const url = `/${etype}/${eid}`;
-        const options = {
-            method: 'PATCH',
-            headers: {
-                'Content-Type': 'application/json',
-            },
-            body: JSON.stringify(attributes),
-        };
-        return this.hypermediaClient.jsonFetch(url, options);
+        return this.hypermediaClient.updateResource(url, attributes);
     }
 
     getTransitionsSchema(etype, eid) {
--- a/src/services/hypermedia.js	Fri Apr 28 16:08:02 2017 +0200
+++ b/src/services/hypermedia.js	Fri Apr 28 16:42:00 2017 +0200
@@ -98,6 +98,17 @@
             });
     }
 
+    updateResource(url, data) {
+        const options = {
+            method: 'PATCH',
+            headers: {
+                'Content-Type': 'application/json',
+            },
+            body: JSON.stringify(data),
+        };
+        return this.jsonFetch(url, options);
+    }
+
     deleteResource(url) {
         const options = {
             method: 'DELETE',