@websm/authfetch
v1.0.0
Published
## Usage
Downloads
2
Readme
fetch method for personal area and authorization required requests
Usage
install package
yarn add @websm/authfetch
put this code
import authfetch from '@websm/authfetch';
let params = {
method: "PATCH",
body: JSON.stringify([
{"op": "add", "path": "/name", value: "Bob"}
]),
}
try {
let response = await authfetch("/api/user", params);
} catch (e) {
if (e.name == 'AuthError')
console.log(e.message);
else throw e;
}