laravel-request 1.1.16 → 1.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/readme.md +42 -4
- package/src/Api.js +6 -1
- package/src/Builder.js +4 -3
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
Install
|
|
2
|
+
|
|
3
|
+
npm install laravel-request
|
|
4
|
+
|
|
5
|
+
Connected package
|
|
6
|
+
|
|
7
|
+
https://github.com/olegstan/laravel-rest
|
|
8
|
+
|
|
9
|
+
|
|
1
10
|
Usage get data
|
|
2
11
|
|
|
3
12
|
```
|
|
@@ -8,12 +17,32 @@ Api.get('active-trade', 'index')
|
|
|
8
17
|
.with('from_account', 'from_account.currency')
|
|
9
18
|
.orderBy('trade_at', 'DESC')
|
|
10
19
|
.all((response) => {
|
|
11
|
-
|
|
20
|
+
//success
|
|
21
|
+
}, () => {
|
|
22
|
+
//error
|
|
12
23
|
})
|
|
13
|
-
.bind(this, 'trades')
|
|
14
24
|
}}
|
|
15
25
|
```
|
|
16
|
-
|
|
26
|
+
|
|
27
|
+
or
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
Api.get('active-trade', 'index')
|
|
31
|
+
.where('id', 115)
|
|
32
|
+
.with('currency')
|
|
33
|
+
.with('to_account', 'to_account.currency')
|
|
34
|
+
.with('from_account', 'from_account.currency')
|
|
35
|
+
.orderBy('trade_at', 'DESC')
|
|
36
|
+
.first((response) => {
|
|
37
|
+
//success
|
|
38
|
+
|
|
39
|
+
}, () => {
|
|
40
|
+
//error
|
|
41
|
+
})
|
|
42
|
+
}}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
|
|
17
46
|
You can use
|
|
18
47
|
|
|
19
48
|
all or first or paginate
|
|
@@ -31,4 +60,13 @@ Api.post('active', 'store', {
|
|
|
31
60
|
}, (response) => {
|
|
32
61
|
//error
|
|
33
62
|
});
|
|
34
|
-
```
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
response must be like below, for 200 status should contains key "result" with text "success"
|
|
66
|
+
|
|
67
|
+
{
|
|
68
|
+
"meta": [],
|
|
69
|
+
"result": "success",
|
|
70
|
+
"data": [],
|
|
71
|
+
}
|
|
72
|
+
|
package/src/Api.js
CHANGED
|
@@ -9,6 +9,11 @@ export default class Api {
|
|
|
9
9
|
*/
|
|
10
10
|
static requestClass = ApiRequest;
|
|
11
11
|
|
|
12
|
+
static tokenResolver = async () =>
|
|
13
|
+
{
|
|
14
|
+
return localStorage.getItem('api_token');
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
/**
|
|
13
18
|
*
|
|
14
19
|
* @param controller
|
|
@@ -147,7 +152,7 @@ export default class Api {
|
|
|
147
152
|
try {
|
|
148
153
|
headers['Content-Type'] = 'application/json';
|
|
149
154
|
|
|
150
|
-
let api_token =
|
|
155
|
+
let api_token = await Api.tokenResolver();
|
|
151
156
|
if (api_token)
|
|
152
157
|
{
|
|
153
158
|
headers["Authorization"] = api_token;
|
package/src/Builder.js
CHANGED
|
@@ -21,14 +21,15 @@ export default class Builder {
|
|
|
21
21
|
'orWhereHasMorph',
|
|
22
22
|
'whereDoesntHave',
|
|
23
23
|
'orWhereDoesntHave',
|
|
24
|
-
|
|
25
|
-
'orderBy',
|
|
26
|
-
'groupBy',
|
|
27
24
|
'whereNull',
|
|
28
25
|
'orWhereNull',
|
|
29
26
|
'whereNotNull',
|
|
30
27
|
'orWhereNotNull',
|
|
31
28
|
|
|
29
|
+
|
|
30
|
+
'orderBy',
|
|
31
|
+
'groupBy',
|
|
32
|
+
|
|
32
33
|
'with',
|
|
33
34
|
'withCount',
|
|
34
35
|
'offset',
|