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

Commit 5285c85

Browse files
committed
only merge request when is a GET request
1 parent c68d711 commit 5285c85

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

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)