Comparing version 0.1.78 to 0.1.79
@@ -21,2 +21,6 @@ "use strict"; | ||
return JSON.stringify(bodyAs2ndParam); | ||
if (utils_1.isBrowser && | ||
(bodyAs2ndParam instanceof FormData || | ||
bodyAs2ndParam instanceof URLSearchParams)) | ||
return bodyAs2ndParam; | ||
return JSON.stringify({}); | ||
@@ -23,0 +27,0 @@ })(); |
{ | ||
"name": "use-http", | ||
"version": "0.1.78", | ||
"homepage": "https://codesandbox.io/embed/km04k9k9x5", | ||
"version": "0.1.79", | ||
"homepage": "http://use-http.com", | ||
"main": "dist/index.js", | ||
@@ -28,11 +28,12 @@ "license": "MIT", | ||
"@typescript-eslint/parser": "^1.11.0", | ||
"eslint": "5.16.0", | ||
"eslint": "^6.0.1", | ||
"eslint-config-prettier": "4.3.0", | ||
"eslint-plugin-jest": "22.6.4", | ||
"eslint-plugin-jest-formatting": "0.0.9", | ||
"eslint-plugin-jest": "22.13.6", | ||
"eslint-plugin-jest-formatting": "0.1.0", | ||
"eslint-plugin-jsx-a11y": "^6.2.1", | ||
"eslint-plugin-prettier": "^3.1.0", | ||
"eslint-plugin-react": "^7.13.0", | ||
"eslint-plugin-react-hooks": "^1.6.0", | ||
"eslint-plugin-react": "^7.14.2", | ||
"eslint-plugin-react-hooks": "^1.6.1", | ||
"eslint-plugin-sonarjs": "^0.4.0", | ||
"eslint-watch": "^5.1.2", | ||
"jest": "^24.7.1", | ||
@@ -39,0 +40,0 @@ "jest-fetch-mock": "^2.1.2", |
@@ -86,3 +86,44 @@ <a href="http://use-http.com"> | ||
<details><summary><b>Basic Usage <code>useFetch</code></b></summary> | ||
<details open><summary><b>Basic Usage (managed state) <code>useFetch</code></b></summary> | ||
```js | ||
import useFetch from 'use-http' | ||
function Todos() { | ||
const [todos, setTodos] = useState([]) | ||
const request = useFetch('https://example.com') | ||
// on mount, initialize the todos | ||
useEffect(() => { | ||
initializeTodos() | ||
}, []) | ||
async function initializeTodos() { | ||
const initialTodos = await request.get('/todos') | ||
setTodos(initialTodos) | ||
} | ||
async function addTodo() { | ||
const newTodo = await request.post('/todos', { | ||
title: 'no way', | ||
}) | ||
setTodos(oldTodos => [...oldTodos, newTodo]) | ||
} | ||
return ( | ||
<> | ||
<button onClick={addTodo}>Add Todo</button> | ||
{request.error && 'Error!'} | ||
{request.loading && 'Loading...'} | ||
{todos.length > 0 && todos.map(todo => ( | ||
<div key={todo.id}>{todo.title}</div> | ||
)} | ||
</> | ||
) | ||
} | ||
``` | ||
</details> | ||
<details><summary><b>Basic Usage (no managed state) <code>useFetch</code></b></summary> | ||
@@ -119,3 +160,2 @@ ```js | ||
<details><summary><b>Destructured <code>useFetch</code></b></summary> | ||
@@ -433,10 +473,5 @@ | ||
- [ ] maybe add a `retry: 3` which would specify the amount of times it should retry before erroring out | ||
- [ ] ERROR handling: | ||
- [ ] make sure `options` (as 2nd param) to all hooks except `useMutation` and `useQuery` is an object, if not `invariant`/throw error | ||
- [ ] add array destructuring return types for helper hooks | ||
- [ ] make GraphQL work with React Suspense | ||
- [ ] make GraphQL examples in codesandbox | ||
- [ ] Documentation: | ||
- [ ] add preview image | ||
- [ ] add google analytics | ||
- [ ] show comparison with Apollo | ||
@@ -443,0 +478,0 @@ - [ ] maybe add syntax for inline headers like this |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
69799
710
546
29