Skip to content

Commit

Permalink
Shorten table content, change object function to enumerable only and …
Browse files Browse the repository at this point in the history
…lexicon
  • Loading branch information
D-Marc1 committed May 17, 2020
1 parent 6397628 commit 7fe5593
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
24 changes: 8 additions & 16 deletions README.md
Expand Up @@ -78,8 +78,6 @@ thin wrapper. The main advantages over vanilla `Fetch` are as follows:
- [Catching Exceptions Manually](#catching-exceptions-manually)
- [Empty Try/Catch](#empty-trycatch)
- [API](#api)
- [Classes](#classes)
- [Typedefs](#typedefs)
- [FarFetch](#farfetch)
- [new FarFetch([options])](#new-farfetchoptions)
- [farFetch.setDefaultOptions([...options])](#farfetchsetdefaultoptionsoptions)
Expand All @@ -92,12 +90,6 @@ thin wrapper. The main advantages over vanilla `Fetch` are as follows:
- [farFetch.head(url, [...options]) ⇒ <code>Promise.&lt;ResponsePlus&gt;</code>](#farfetchheadurl-options--promiseresponseplus)
- [FarFetchError ⇐ <code>Error</code>](#farfetcherror--error)
- [new FarFetchError(message)](#new-farfetcherrormessage)
- [RequestException : <code>object</code>](#requestexception--object)
- [ResponsePlus : <code>object</code>](#responseplus--object)
- [errorHandlerCallback : <code>function</code>](#errorhandlercallback--function)
- [afterSendCallback : <code>function</code>](#aftersendcallback--function)
- [errorMsgTemplateCallback ⇒ <code>string</code>](#errormsgtemplatecallback--string)
- [RequestOptions : <code>object</code>](#requestoptions--object)

## Passing in Data to Request

Expand Down Expand Up @@ -191,12 +183,12 @@ async addPerson() {
}
```

Notice how it's completely predictable and doesn't require you to throw an
exception if it's not a `200` status code. Notice how it's not much different
than any other request with FarFetch. Sure, it's not horrible anymore in regular
Javascript, thanks to features like `URLSearchParams` and `Object.entries`, but
it's so much easier to not have to think much when you program. `FarFetch`'s
consistent API makes it a breeze to make any sort of request.
Notice how each request is completely predictable in `FarFetch` and doesn't
require you to throw an exception if it's not a `200` status code. Sure, using
the native javascript `Fetch API` isn't horrible anymore in regular Javascript,
thanks to features like `URLSearchParams` and `Object.entries`, but it's so much
easier to not have to think much when you program. `FarFetch`'s consistent API
makes it a breeze to make any sort of request.

## Uploading Files

Expand Down Expand Up @@ -339,8 +331,8 @@ async uploadFiles() {

Look at how much more comprehensible the code becomes with `FarFetch`. This is
practically even readable by a non-programmer, as this reads as: *Let's add a 22
year old man named Bobby, along with uploading his following files: photos,
videos and documents*.
year old man named Bobby and upload his following files: photos, videos and
documents*.

## Passing in Fetch API init options

Expand Down
2 changes: 1 addition & 1 deletion src/far-fetch.js
Expand Up @@ -252,7 +252,7 @@ export default class FarFetch {
// File upload shouldn't have a content supplied; it will auto-detect
delete options.headers?.['Content-Type'];
// Data object has at least one property
} else if (Object.getOwnPropertyNames(data).length > 0) {
} else if (Object.keys(data).length > 0) {
// Can't be used in body
if (options.method === 'GET' || options.method === 'DELETE' || options.method === 'HEAD') {
queryString = `?${new URLSearchParams(Object.entries(data))}`;
Expand Down

0 comments on commit 7fe5593

Please sign in to comment.