Skip to content
This repository was archived by the owner on Aug 18, 2018. It is now read-only.

Commit 491e600

Browse files
committed
solve problem with duplicated http request (only get now)
1 parent c68d711 commit 491e600

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ app.config(['rsJsonapiConfig', (rsJsonapiConfig) => {
5151
}]);
5252

5353
var MyController = function(JsonapiCore) {
54-
// ...
54+
// ...
5555
}
5656
MyController.$inject = ['JsonapiCore'];
5757
```
@@ -62,6 +62,10 @@ Like you know, the better way is with examples. Based on [endpoints example libr
6262

6363
### Defining a resource
6464

65+
1. hola
66+
2. hola 2
67+
3. hola
68+
6569
`authors.service.ts`
6670

6771
```typescript
@@ -196,9 +200,10 @@ let author = AuthorsService.get('some_author_id');
196200
this.author.attributes.name += 'New Name';
197201
this.author.save(success => {
198202
console.log('author saved!');
199-
});
203+
});
200204
````
201205

206+
````
202207
### Handling errors
203208
204209
### Pagination
@@ -256,3 +261,4 @@ gulp dist
256261
```
257262
258263
And commit! Don't forget your pull request :)
264+
````

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-angular-jsonapi",
3-
"version": "0.4.14",
3+
"version": "0.4.15",
44
"description": "JSONAPI library developed for AngularJS in Typescript",
55
"repository": {
66
"type": "git",

src/library/services/http.service.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ export class Http {
2222
}
2323

2424
public get(path: string) {
25-
return this.exec(path, 'GET');
25+
return this.exec(path, 'get');
2626
}
2727

2828
protected exec(path: string, method: string, data?: IDataObject, call_loadings_error:boolean = true) {
2929

30-
// http request (if we don't have any one yet)
31-
if (!this.noDuplicatedHttpCallsService.hasPromises(path)) {
30+
// http request (if we don't have any GET request yet)
31+
if (method !== 'get' || !this.noDuplicatedHttpCallsService.hasPromises(path)) {
3232
let req = {
3333
method: method,
3434
url: this.rsJsonapiConfig.url + path,
@@ -37,12 +37,17 @@ export class Http {
3737
}
3838
};
3939
data && (req['data'] = data);
40-
let http_promise = this.$http(req);
40+
var http_promise = this.$http(req);
4141

42-
this.noDuplicatedHttpCallsService.setPromiseRequest(path, http_promise);
42+
if (method === 'get') {
43+
this.noDuplicatedHttpCallsService.setPromiseRequest(path, http_promise);
44+
} else {
45+
var fakeHttpPromise = http_promise;
46+
}
47+
}
48+
if (method === 'get') {
49+
var fakeHttpPromise = this.noDuplicatedHttpCallsService.getAPromise(path);
4350
}
44-
45-
let fakeHttpPromise = this.noDuplicatedHttpCallsService.getAPromise(path);
4651

4752
let deferred = this.$q.defer();
4853
let self = this;

0 commit comments

Comments
 (0)