getta 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,14 +109,11 @@ The stream reader to use when parsing the response body. Default is `'json'`.
|
|
|
109
109
|
|
|
110
110
|
### Making reqeusts
|
|
111
111
|
|
|
112
|
-
The rest client supports `GET`, `POST`, `PUT` and `DELETE` methods and has functions for each method.
|
|
112
|
+
The rest client supports `GET`, `POST`, `PUT` and `DELETE` methods and has functions for each method. The first argument is the path to make the request to. This can also be a path template with variable placeholders that will be replaced with data passed in on the `pathTemplateData` request option.
|
|
113
113
|
|
|
114
114
|
```typescript
|
|
115
|
-
const pathTemplate = '/direct/rest/content/catalog/{type}/{id,+}?format={brief|standard}';
|
|
116
|
-
const pathTemplateData = { 'brief|standard': 'standard', 'id,+': '136-7317', type: 'product' };
|
|
117
|
-
|
|
118
115
|
// GET
|
|
119
|
-
const getResponse = await restClient.get(
|
|
116
|
+
const getResponse = await restClient.get('/path/to/resource');
|
|
120
117
|
|
|
121
118
|
// POST
|
|
122
119
|
const postResponse = await restClient.post('/graphql/api', {
|
|
@@ -124,13 +121,12 @@ const postResponse = await restClient.post('/graphql/api', {
|
|
|
124
121
|
});
|
|
125
122
|
|
|
126
123
|
// PUT
|
|
127
|
-
const putResponse = await restClient.put(
|
|
124
|
+
const putResponse = await restClient.put('/path/to/resource', {
|
|
128
125
|
body: JSON.stringify({ /* payload */ }),
|
|
129
|
-
pathTemplateData,
|
|
130
126
|
});
|
|
131
127
|
|
|
132
128
|
// DELETE
|
|
133
|
-
const deleteResponse = await restClient.delete(
|
|
129
|
+
const deleteResponse = await restClient.delete('/path/to/resource');
|
|
134
130
|
```
|
|
135
131
|
|
|
136
132
|
### Request options
|