Skip to content

Commit 45f124a

Browse files
committed
Ready for v1.1.0
1 parent 6e3b0f2 commit 45f124a

17 files changed

+365
-617
lines changed

README.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Then you will need to use it in your application :
1818

1919
* \>= ES6 : `import $json from "@voltra/json"`
2020
* Node (<ES6) : `const $json = require("@voltra/json")`
21-
* In your HTML files : `<script src="your/path/to/jsonclient.js"></script>` (exposes the variable `$json`)
21+
* In your HTML files : `<script src="your/path/to/dist/jsonclient.js"></script>` (exposes the variable `$json`)
2222

2323

2424

@@ -62,7 +62,66 @@ $json.post :: (
6262

6363

6464

65-
If you have any doubts, you could refer to [Mozilla's guide on how to provide options to `fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Supplying_request_options) or ask for advices on my Discord server.
65+
If you have any doubts, you could refer to [Mozilla's guide on how to provide options to `fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#Supplying_request_options) or ask for advices on my [Discord server](https://discord.gg/JtWAjbw).
66+
67+
## Hooks and defaults
68+
69+
There are a few ways you can customize your JSON client (POST requests only) :
70+
71+
* Pass your custom settings as the third argument
72+
* Change the default values
73+
74+
75+
76+
Default values are located in the object `$json.defaults` and are classified per HTTP methods (only those supported).
77+
78+
79+
80+
## Dependencies
81+
82+
There are only two dependencies :
83+
84+
* [fetchJSON](https://www.npmjs.com/package/fetch_json) : Used in developpement as the GET request provider (I'm the on that needs it)
85+
* The Fetch API or `fetch` : As part of the Fetch API, `fetch` allows to emit HTTP requests. This library is heavily based around this function and therefore requires it, modern browsers implement it but there are also a lot of polyfills out there, here are two of them :
86+
* [whatwg-fetch](https://www.npmjs.com/package/whatwg-fetch) : For old browsers
87+
* [node-fetch](https://www.npmjs.com/package/node-fetch) : For Node-based environments
88+
89+
90+
91+
## Troubleshooting
92+
93+
If you don't find an answer to your problem, feel free to ask for help on my [Discord server](https://discord.gg/JtWAjbw).
94+
95+
96+
97+
**I can't use this library except by including it directly in the HTML**
98+
99+
> Until v1.1.0, there was an issue were the build process would simplify a conditional occuring in the UMD which would break the code for usage outside of the browser.
100+
>
101+
> This has been fixed in v1.1.0 by simply declaring the transpiled `build-babel/jsonclient.esm.js` file as the entry point of the application, thus making it available to use everywhere. As a sidenote, I'd like to point out that direct usage in the browser is done by including `dist/jsonclient.js` (which is not the entry point anymore).
102+
>
103+
>
104+
>
105+
> Make sure that the version of the library you have is at least 1.1.0 (check the `package.json` file), if not update it for the latest version.
106+
>
107+
> If you're still having this problem post v1.1.0, feel free to [open an issue on GitHub]("url here boi").
108+
109+
110+
111+
**I cannot find `$json.postOptions`, where are they ?**
112+
113+
> Since v1.1.0, `$json.postOptions` has been renamed `$json.postOptionsEnums` in order to avoid any kind of confusion.
114+
115+
116+
117+
**I am unable to get the requested data, there is an error in the console : `"Something went wrong during data inspection (data is not JSON or couldn't reach file)"`**
118+
119+
> This can mean two things (as said in the error message) :
120+
>
121+
> - The data is not **explicitely** marked as json (needs the`content-type` to be `application/json`, which is the standard way of identifying JSON)
122+
> - The client was unable to reach the requested data (typo, wrong URL/URI, etc...)
123+
124+
66125

67126
---
68127

build-babel/enums/Cache.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build-babel/enums/Credentials.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build-babel/enums/Mode.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build-babel/enums/Redirect.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build-babel/enums/Referrer.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build-babel/jsonclient.js

Lines changed: 69 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)