comic-vine-sdk 1.1.0 → 1.1.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.
Files changed (2) hide show
  1. package/README.md +37 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -5,11 +5,11 @@ The Comic Vine SDK provides convenient access to the [Comic Vine API][comic-vine
5
5
  ## Table of Contents
6
6
 
7
7
  - [Installation](#installation)
8
- - [Browser Support](#browser-support)
9
8
  - [Roadmap](#roadmap)
10
9
  - [Comic Vine Resources](#comic-vine-resources)
11
10
  - [Usage/Examples](#usageexamples)
12
11
  - [Initialization](#initialization)
12
+ - [Options](#options)
13
13
  - [Fetch a single resource](#fetch-a-single-resource)
14
14
  - [Fetch a resource list](#fetch-a-resource-list)
15
15
  - [Limit the fields in the response payload](#limit-the-fields-in-the-response-payload)
@@ -27,18 +27,12 @@ npm install comic-vine-sdk
27
27
  yarn add comic-vine-sdk
28
28
  ```
29
29
 
30
- ## Browser support
31
-
32
- This package does not currently work in a web browser, the Comic Vine API does not allow [cross-origin](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) requests. The recommended approach would be to use it server side, however, in a future update an option to set the baseUrl will be added. This option could be used to proxy the request assuming you have some safe way for the web client to fetch your api key, you don't want to send the api key to the browser in your JS bundle.
33
-
34
30
  ## TypeScript Typings
35
31
 
36
32
  There's a good change you may find an issue with the typings in the API response objects. They were generated using sample data from the API, if you find a problem [open an issue](https://github.com/AllyMurray/comic-vine/issues/new) detailing the problem along with the request details so I can add that request to the sample dataset. While you wait for it to be fixed add `// @ts-expect-error` above the line causing the problem. This will allow you to compile in the meantime but will flag when the problem has been fixed.
37
33
 
38
34
  ## Roadmap
39
35
 
40
- - Add option to set baseUrl when initializing the library
41
-
42
36
  - Automatic Pagination
43
37
 
44
38
  - Expandable responses
@@ -109,6 +103,42 @@ const comicVine = new ComicVine('your-api-key-here');
109
103
  })();
110
104
  ```
111
105
 
106
+ ### Options
107
+
108
+ The second parameter of the constructor accepts options to configure the library
109
+
110
+ ```js
111
+ new ComicVine('your-api-key-here', options);
112
+ ```
113
+
114
+ ### `baseUrl`
115
+
116
+ **Type: <code>string | undefined</code>**
117
+
118
+ **Default: https://comicvine.gamespot.com/api/**
119
+
120
+ If using the package in node then leave this as the default value. The Comic Vine API does not allow [cross-origin](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) requests. This option could be used to proxy the request assuming you have some safe way for the web client to fetch your api key, you don't want to send the api key to the browser in your JS bundle.
121
+
122
+ ```js
123
+ import ComicVine from 'comic-vine-sdk';
124
+
125
+ // This is just an example, to try it out you would
126
+ // have to visit (https://cors-anywhere.herokuapp.com)
127
+ // to request temporary access.
128
+ const comicVine = new ComicVine('your-api-key-here', {
129
+ baseUrl: 'https://cors-anywhere.herokuapp.com/https://www.comicvine.com/api/',
130
+ });
131
+
132
+ (async () => {
133
+ try {
134
+ const publisher = await comicVine.publisher.retrieve(1859);
135
+ console.log(publisher.name);
136
+ } catch (error) {
137
+ console.error(error);
138
+ }
139
+ })();
140
+ ```
141
+
112
142
  ### Fetch a single resource
113
143
 
114
144
  All resources have a retrieve method, the following example retrieves a publisher
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comic-vine-sdk",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "A JS/TS client for the Comic Vine API",
5
5
  "keywords": [
6
6
  "comic",