mirror of https://github.com/01-edu/public.git
docs(get-json): correct grammar
This commit is contained in:
parent
a55dccefd6
commit
bf06961810
|
@ -4,26 +4,23 @@
|
|||
|
||||
In this exercise, we will focus on building complex async flows with promises.
|
||||
|
||||
Create a `getJSON` function that takes 2 parameters:
|
||||
Create a function named `getJSON` with two parameters:
|
||||
- `path`: a URL called by your function.
|
||||
- `params`: optional query parameters that will be appended to the `path`.
|
||||
|
||||
- `path`, that will be the url called by your function
|
||||
- `params` _optional_, that will be the search parameters appended to your url
|
||||
`getJSON` must construct a valid url with the `path` and stringified `params`, and use `fetch` to fulfil the request.
|
||||
|
||||
`getJSON` must construct a valid url with the `path` and stringified `params`
|
||||
and call `fetch` with it.
|
||||
If the response is not ok, your function must throw an error using
|
||||
the response status message.
|
||||
If the response is not OK, `getJSON` must throw an error using the response _status text_.
|
||||
|
||||
The response body must then be read and parsed from json.
|
||||
The response body must then be read and parsed from JSON.
|
||||
|
||||
The parsed object contains one of those 2 properties:
|
||||
|
||||
- `"data"` the actual data to return
|
||||
- `"error"` the error message to throw
|
||||
- `"data"`: the actual data to return.
|
||||
- `"error"`: the error message to throw.
|
||||
|
||||
### Notions
|
||||
|
||||
- [nan-academy.github.io/js-training/examples/promise.js](https://nan-academy.github.io/js-training/examples/promise.js)
|
||||
- [devdocs.io/dom/fetch_api/using_fetch](https://devdocs.io/dom/fetch_api/using_fetch)
|
||||
- [devdocs.io/dom/urlsearchparams](https://devdocs.io/dom/urlsearchparams)
|
||||
- [devdocs.io/javascript/global_objects/json](https://devdocs.io/javascript/global_objects/json)
|
||||
- [Promise.js](https://nan-academy.github.io/js-training/examples/promise.js)
|
||||
- [Using fetch](https://devdocs.io/dom/fetch_api/using_fetch)
|
||||
- [URL search params](https://devdocs.io/dom/urlsearchparams)
|
||||
- [JSON](https://devdocs.io/javascript/global_objects/json)
|
||||
|
|
Loading…
Reference in New Issue