Import the postman_collection.json
.
-
CREATE / POST
var data = { "data": { "type": "user", "attributes": { "username": "test", "password": "test" } } }; fetch('http://localhost:8080/api/user', { method: 'POST', headers: { 'Accept': 'application/vnd.api+json', 'Content-Type': 'application/vnd.api+json', }, body: JSON.stringify(data), }) .then(response => response.ok && response.json()) .then(json => console.log(json));
-
QUERY / GET
fetch('http://localhost:8080/api/user?page[number]=1&page[size]=3&page[totals]', { method: 'GET', headers: { 'Accept': 'application/vnd.api+json', }, }) .then(response => response.ok && response.json()) .then(json => console.log(json));
-
UPDATE / PATCH
var data = { "data": { "id": "1", "type": "user", "attributes": { "username": "test", "encodedPassword": "test" } } }; fetch('http://localhost:8080/api/user/1', { method: 'PATCH', headers: { 'Accept': 'application/vnd.api+json', 'Content-Type': 'application/vnd.api+json', }, body: JSON.stringify(data), }) .then(response => console.log(response.status === 204 ? 'ok' : 'failure'));
-
DELETE / DELETE
fetch('http://localhost:8080/api/user/1', { method: 'DELETE', headers: { 'Accept': 'application/vnd.api+json', }, }) .then(response => console.log(response.status === 204 ? 'ok' : 'failure'));
More information about Elide can be found at elide github repo and elide.io.