Skip to content

Commit

Permalink
Merge pull request #50 from ahabeb/master
Browse files Browse the repository at this point in the history
fixes on how to use $http call
  • Loading branch information
mkuhnsbuildfire authored Sep 27, 2016
2 parents 6fbc126 + 00099e6 commit 3420655
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 48 deletions.
49 changes: 29 additions & 20 deletions control/content/app.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
postDataObject.params.externalAppId = appId;
postDataObject.apiKey = API_KEY.value;
var successCallback = function (response) {
console.log('Resolve in add application Api-------------------',response);
console.log('Resolve in add application Api-------------------', response);
return deferred.resolve(response);
};
var errorCallback = function (err) {
return deferred.reject(err);
};
$http({
method: 'GET',
url: SERVER_URL.link+'?data='+ JSON.stringify(postDataObject),
url: SERVER_URL.link,
params: {data: postDataObject},
headers: {'Content-Type': 'application/json'}
}).then(successCallback, errorCallback);
return deferred.promise;
Expand All @@ -42,11 +43,11 @@
postDataObject.method = 'thread/getThread';
postDataObject.params = {};
postDataObject.params.appId = socialAppId;
postDataObject.params.uniqueLink = encodeURIComponent(context.appId + context.instanceId);
postDataObject.params.uniqueLink = context.appId + context.instanceId;
postDataObject.params.userToken = null;
postDataObject.params.title = context.pluginTitle || null;
postDataObject.params.title = encodeURIComponent(postDataObject.params.title);
postDataObject.userToken = null;
postDataObject.params.title = postDataObject.params.title;
postDataObject.userToken = null;
var successCallback = function (response) {
console.log('thread/getThread in content callback recieved--------------', response);
return deferred.resolve(response);
Expand All @@ -57,7 +58,8 @@
};
$http({
method: 'GET',
url: SERVER_URL.link + '?data=' + JSON.stringify(postDataObject),
url: SERVER_URL.link,
params: {data: postDataObject},
headers: {'Content-Type': 'application/json'}
}).then(successCallback, errorCallback);
return deferred.promise;
Expand All @@ -68,22 +70,23 @@
postDataObject.id = '1';
postDataObject.method = 'thread/findByPage';
postDataObject.params = {};
postDataObject.params.appId = data.socialAppId;
postDataObject.params.appId = data.socialAppId;
postDataObject.params.parentThreadId = data.parentThreadId;
postDataObject.params.lastThreadId = data.lastThreadId;
postDataObject.userToken = null;
var successCallback = function (response) {

console.log('Get items---------------------------in content',response);
console.log('Get items---------------------------in content', response);
return deferred.resolve(response);
};
var errorCallback = function (err) {
console.log('Get items----------error-----------------in content',err);
console.log('Get items----------error-----------------in content', err);
return deferred.reject(err);
};
$http({
method: 'GET',
url: SERVER_URL.link+'?data='+ JSON.stringify(postDataObject),
url: SERVER_URL.link,
params: {data: postDataObject},
headers: {'Content-Type': 'application/json'}
}).then(successCallback, errorCallback);
return deferred.promise;
Expand All @@ -104,12 +107,13 @@
};
$http({
method: 'GET',
url: SERVER_URL.link + '?data='+ JSON.stringify(postDataObject),
url: SERVER_URL.link,
params: {data: postDataObject},
headers: {'Content-Type': 'application/json'}
}).then(successCallback, errorCallback);
return deferred.promise;
},
deletePost: function (postId, socialAppId,secureToken) {
deletePost: function (postId, socialAppId, secureToken) {
var deferred = $q.defer();
var postDeleteObject = {};
postDeleteObject.id = '1';
Expand All @@ -128,12 +132,13 @@
};
$http({
method: 'GET',
url: SERVER_URL.link + '?data='+ JSON.stringify(postDeleteObject),
url: SERVER_URL.link,
params: {data: postDeleteObject},
headers: {'Content-Type': 'application/json'}
}).then(successCallback, errorCallback);
return deferred.promise;
},
getCommentsOfAPost:function(data) {
getCommentsOfAPost: function (data) {
var deferred = $q.defer();
var postDataObject = {};
postDataObject.id = '1';
Expand All @@ -153,7 +158,8 @@
};
$http({
method: 'GET',
url: SERVER_URL.link + '?data=' + JSON.stringify(postDataObject),
url: SERVER_URL.link,
params: {data: postDataObject},
headers: {'Content-Type': 'application/json'}
}).then(successCallback, errorCallback);
return deferred.promise;
Expand Down Expand Up @@ -181,12 +187,13 @@
};
$http({
method: 'GET',
url: SERVER_URL.link + '?data=' + JSON.stringify(postDataObject),
url: SERVER_URL.link,
params: {data: postDataObject},
headers: {'Content-Type': 'application/json'}
}).then(successCallback, errorCallback);
return deferred.promise;
},
deleteComment: function (commentId, threadId, socialAppId,secureToken) {
deleteComment: function (commentId, threadId, socialAppId, secureToken) {
var deferred = $q.defer();
var postDeleteObject = {};
postDeleteObject.id = '1';
Expand All @@ -206,13 +213,14 @@
};
$http({
method: 'GET',
url: SERVER_URL.link + '?data='+ JSON.stringify(postDeleteObject),
url: SERVER_URL.link,
params: {data: postDeleteObject},
headers: {'Content-Type': 'application/json'}
}).then(successCallback, errorCallback);
return deferred.promise;
},
getThreadLikes: function (uniqueIds, socialAppId) {
console.log('Unique Ids------------------------',uniqueIds);
console.log('Unique Ids------------------------', uniqueIds);
var deferred = $q.defer();
var postDataObject = {};
postDataObject.id = '1';
Expand All @@ -229,7 +237,8 @@
};
$http({
method: 'GET',
url: SERVER_URL.link + '?data=' + JSON.stringify(postDataObject),
url: SERVER_URL.link,
params: {data: postDataObject},
headers: {'Content-Type': 'application/json'}
}).then(success, error);
return deferred.promise;
Expand Down
Loading

0 comments on commit 3420655

Please sign in to comment.