Closed
Description
I have two functions that this is happening to...
First
Parse.Cloud.define("GetKeys", function(request, response) {
var appKey = "APP_KEY";
var singleKey = "SINGLE_KEY";
var jsonObject = {
"appkey": appKey,
"singleKey" : singleKey
};
success: function() {
response.success(jsonObject);
}
}, { useMasterKey: true });
I get a bad json response for this.
Here is my call...
HashMap<String, Object> params = new HashMap<String, Object>();
ParseCloud.callFunctionInBackground("GetKeys", params, new FunctionCallback<Map<String, Object>>() {
public void done(Map<String, Object> mapObject, ParseException e) {
if (e == null) {
appKey = mapObject.get("appkey").toString();
singleKey = mapObject.get("singleKey").toString();
SharedPreferences sharedPreferences = getApplicationContext().getSharedPreferences(SHARED_PREF, MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putString("appKey", appKey);
editor.putString("singleKey", singleKey);
editor.apply();
doInBackground();
} else {
//log error
}
}
});
I also have this cloud functions as well...
Parse.Cloud.define("SaveSearchByDevice", function(request, response) {
const UserSearch = Parse.Object.extend("UserSearch");
const userSearch = new UserSearch();
userSearch.set("deviceManufacturer", request.params.deviceManufacturer);
userSearch.set("deviceModel", request.params.deviceModel);
userSearch.set("deviceRelease", request.params.deviceRelease);
userSearch.set("deviceSDKName", request.params.deviceSDKName);
userSearch.set("userDeviceCodename", request.params.userDeviceCodename);
userSearch.set("userSearchedFor", request.params.userSearchedFor);
userSearch.set("userLocation", request.params.userLocation);
userSearch.save()
.then((userSearch) => {
// Execute any logic that should take place after the object is saved.
response.success('saved');
}, (error) => {
// Execute any logic that should take place if the save fails.
// error is a Parse.Error with an error code and message.
response.error('error: ' + error.message);
});
}, { useMasterKey: true });
And my code for this...
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("deviceManufacturer", deviceManufacturer);
params.put("deviceModel", deviceModel);
params.put("deviceRelease", deviceRelease);
params.put("deviceSDKName", deviceSDKName);
params.put("userDeviceCodename", deviceCodename);
params.put("userSearchedFor", itemDescription);
params.put("userLocation", userLocation);
ParseCloud.callFunctionInBackground("SaveSearchByDevice", params, new FunctionCallback< Map<String, Object> >() {
public void done(Map<String, Object> mapObject, ParseException e) {
if (e == null){
//saved
} else {
//print e.getmessage() = badjsonresponse
}
}
});
Thanks.
Metadata
Metadata
Assignees
Labels
No labels