useFetch is a React hook for simplifying data access.

#### Example

```js static
function TagForm({ initialName }) {
  const [request, loading] = useFetch("/tags");

  const [name, setName] = useState(initialName);

  const handleChange = (event) => {
    setName(event.target.value)
  }


  const handleSubmit = async () => {
    const result = await request.post({ data: { name}})
    // TODO: handle result
  }

  return (
    <div>
      <form onSubmit={handleSubmit}>
        <label htmlFor="name">Name</label>
        <input id="name" value={name} onChange={handleChange} />

        <button type="submit" disabled={loading}/>Submit</button>
      </form>
    </div>
  );
}
```

#### Handling Errors

When you call one of the request methods, any error will throw an error. This is unlike using fetch directly, where only network errors throw. The reason for this is because we want this hook to cover the 90% use case of handling a json response automatically. So, a network error will throw the same error that fetch would throw, and any http error will throw an error with the status code as a message, and a property response that contains the response from the fetch call.

Future, higher level, data fetching hooks will take advantage of a consistent response structure for a cleaner API.


```js static
function handleClick() {
  try {
    const result = await request.post({data: {}})
    // do something with the successful result
  } catch (e) {
    const response = e.response
    const error = await response.json()
    // do something with the error.
  }
}
```