openlayer 0.1.13 → 0.1.14

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -124,7 +124,7 @@ class OpenlayerClient {
124
124
  catch (_c) {
125
125
  const projectsEndpoint = '/projects';
126
126
  const projectsQuery = this.resolvedQuery(projectsEndpoint);
127
- const projectsResponse = yield fetch(projectsQuery, {
127
+ const response = yield fetch(projectsQuery, {
128
128
  body: JSON.stringify({
129
129
  description,
130
130
  name,
@@ -136,9 +136,10 @@ class OpenlayerClient {
136
136
  },
137
137
  method: 'POST',
138
138
  });
139
- const { items: projects } = yield projectsResponse.json();
139
+ const data = yield response.json();
140
+ const { items: projects, error } = data;
140
141
  if (!Array.isArray(projects)) {
141
- throw new Error('Invalid response from Openlayer');
142
+ throw new Error(typeof error === 'string' ? error : 'Invalid response from Openlayer');
142
143
  }
143
144
  const project = projects.find((p) => p.name === name);
144
145
  if (!(project === null || project === void 0 ? void 0 : project.id)) {
@@ -190,16 +191,17 @@ class OpenlayerClient {
190
191
  version: this.version,
191
192
  };
192
193
  const projectsQuery = this.resolvedQuery(projectsEndpoint, projectsQueryParameters);
193
- const projectsResponse = yield fetch(projectsQuery, {
194
+ const response = yield fetch(projectsQuery, {
194
195
  headers: {
195
196
  Authorization: `Bearer ${this.openlayerApiKey}`,
196
197
  'Content-Type': 'application/json',
197
198
  },
198
199
  method: 'GET',
199
200
  });
200
- const { items: projects } = yield projectsResponse.json();
201
+ const data = yield response.json();
202
+ const { items: projects, error } = data;
201
203
  if (!Array.isArray(projects)) {
202
- throw new Error('Invalid response from Openlayer');
204
+ throw new Error(typeof error === 'string' ? error : 'Invalid response from Openlayer');
203
205
  }
204
206
  const project = projects.find((p) => p.name === name);
205
207
  if (!(project === null || project === void 0 ? void 0 : project.id)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openlayer",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "The Openlayer TypeScript client",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",