Skip to content

Commit cf7f239

Browse files
committed
Merge pull request #153 from peterdotjs/serverUrlBatch
Using serverUrl constant for batch requests.
2 parents 33bebc3 + 83e0470 commit cf7f239

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/ParseObject.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ var objectCount = 0;
6565
// behavior in a server scenario
6666
var singleInstance = (!CoreManager.get('IS_NODE'));
6767

68+
function getServerUrlPath() {
69+
var serverUrl = CoreManager.get('SERVER_URL');
70+
if (serverUrl[serverUrl.length - 1] !== '/') {
71+
serverUrl += '/';
72+
}
73+
var url = serverUrl.replace(/https?:\/\//, '');
74+
return url.substr(url.indexOf('/'));
75+
}
76+
6877
/**
6978
* Creates a new model with defined attributes.
7079
*
@@ -1576,7 +1585,7 @@ var DefaultController = {
15761585
requests: batch.map((obj) => {
15771586
return {
15781587
method: 'DELETE',
1579-
path: '/1/classes/' + obj.className + '/' + obj._getId(),
1588+
path: getServerUrlPath() + 'classes/' + obj.className + '/' + obj._getId(),
15801589
body: {}
15811590
};
15821591
})
@@ -1700,7 +1709,7 @@ var DefaultController = {
17001709
return RESTController.request('POST', 'batch', {
17011710
requests: batch.map((obj) => {
17021711
var params = obj._getSaveParams();
1703-
params.path = '/1/' + params.path;
1712+
params.path = getServerUrlPath() + params.path;
17041713
return params;
17051714
})
17061715
}, options);

0 commit comments

Comments
 (0)