axios-easy-auth
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "axios-easy-auth", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Modified axios with a simple addition of headers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
<h1>Were there any problems adding headers to the request?</h1> | ||
<h3>This library makes it easy.</h3> | ||
<br /> | ||
<img src="https://i.ibb.co/XV5q9BB/01.png" alt="Создание класса EasyAuth"> | ||
<pre>const auth = new EasyAuth('https://jsonplaceholder.typicode.com', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9')</pre> | ||
<p> | ||
@@ -9,3 +9,11 @@ First we need to create the EasyAuth class. Parameters accept site url, access token. | ||
<br /> | ||
<img src="https://i.ibb.co/j4Dz4rZ/02.png" alt="POST запрос"> | ||
<pre> | ||
const postData = async () => { | ||
const responce = await auth.post('/posts', {}, {Header: 'value'}) | ||
// post(path: string, body: array, headers: array) | ||
console.log('POST') | ||
console.log(responce.data) | ||
} | ||
</pre> | ||
<p> | ||
@@ -26,9 +34,16 @@ Then you can make requests to the server. | ||
<br /> | ||
<img src="https://i.ibb.co/XV5q9BB/01.png" alt="Создание класса EasyAuth"> | ||
<pre>const auth = new EasyAuth('https://jsonplaceholder.typicode.com', 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9')</pre> | ||
<p> | ||
<pre>`const auth = new EasyAuth('http://site.com', 'Bearer ey251txcfhjguuy45tyhjafduv7ucshnfd')`</pre> | ||
Для начала нужно создать класс EasyAuth. Параметрами принимает url сайта, access токен. | ||
</p> | ||
<br /> | ||
<img src="https://i.ibb.co/j4Dz4rZ/02.png" alt="POST запрос"> | ||
<pre> | ||
const postData = async () => { | ||
const responce = await auth.post('/posts', {}, {Header: 'value'}) | ||
// post(path: string, body: array, headers: array) | ||
console.log('POST') | ||
console.log(responce.data) | ||
} | ||
</pre> | ||
<p> | ||
@@ -35,0 +50,0 @@ Далее можно делать запросы на сервер. |
3892
54