Skip to content

Commit

Permalink
update readme and changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
jd1378 committed Feb 3, 2021
1 parent 29dc09b commit d149739
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@

# Changelog

# v1.1.0

- Very important fix for `ExtendedRequestInit` type. The type is also exported now.
- Very important fix for FormData.
- automatically add method for object body (json).
- automatically build and use form data if `form` is defined inside `init`

# v1.0.0
26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,41 @@ Also adds `Accept` header with value `application/json, text/plain, */*` if not
you can import `wrapFetch` from `mod.ts` file.

```js
export { wrapFetch } from 'https://deno.land/x/fetch_goody@v1.0.0/mod.ts';
export { wrapFetch } from 'https://deno.land/x/fetch_goody@v1.1.0/mod.ts';
```

### wrapFetch

```js
// this simple
const fetch = wrapFetch();
const wrappedfetch = wrapFetch();
```

Or

```js
// you can also pass your own wrapped fetch function, allowing for wrapping fetch multiple times
const fetch = wrapFetch({ fetchFn: yourFetch });
const wrappedfetch = wrapFetch({ fetchFn: yourFetch });
```

#### using the new wrappedfetch

```js

const resp1 = await wrappedfetch("url",{
form: {
'foo': 'bar'
}
}); // sets method to POST by default and converts object to FormData.

// or

const resp2 = await wrappedfetch("url",{
body: {
'foo': 'bar'
}
}); // is sent as json and corresponding header is set
// also if method is not defined for this, it will be set as POST
```

## test
Expand Down

0 comments on commit d149739

Please sign in to comment.