get error when use cloudboost js sdk for user logout function, any idea? - cloudboost

CB.CloudUser.current.logOut({
success: function(user) {
},
error: function(err) {
})(here shows ',' expected);

You're missing a bracket in your JS code. :)

Related

How to debug an issue with Zendesk App as console.log is not working

topBarClient.request(settings).then(
function (data) {
console.log("data",data);
showTaskData(data);
if (data.status === 200) {
onSuccess(JSON.parse(data.responseText));
} else {
onFailure(data.status);
}
},
function (response) {
console.log("error", response);
onFailure(response.status);
}
);
onFailure is working but not able to get the error out
Is there a way to test this locally?
console.log works fine, if it's not working then it is not getting called probably due to some exception in the line above console.log.
If you face any problem you can render html component like div to dislplay the text for debugging purpose.

type error null is not an object (evaluating 'ShareDialog.canShow') in React Native FBSDK

I have followed this GitHub URL to integrate Facebook sharing in my application.
https://github.com/facebook/react-native-fbsdk
Here is my code:
constructor(props){
super(props);
this.state={
shareLinkContent : {
contentType: 'link',
contentDescription: 'Facebook sharing is easy!',
contentUrl: 'https://cabbazar.com',
},
}
shareLinkWithShareDialog() {
var tmp = this;
ShareDialog.canShow(tmp.state.shareLinkContent).then(
function(canShow) {
if (canShow) {
return ShareDialog.show(tmp.state.shareLinkContent);
}
}
).then(
function(result) {
console.log('handle result: ' + result);
},
function(error) {
console.log('Share fail with error: ' + error);
}
);
}
But I am always getting an error in my simulator. Do I need to setup anything in for Xcode?
I checked this url but it is not solving my problem.
null is not an object (evaluating 'ShareDialog.canShow')
Please suggest.
Thanks
Sometimes auto link doesn't work. So you have to link manually using react-native link react-native-fbsdk

Handling error in ajax request in Select2

I need to detect if user session is gone when expanding Select2 combobox. When that condition occurs, response is redirected to login page.
The Select2 is populated using an ajax call, so I have added this to the "ajax" parameter:
transport: function (params, success, failure) {
var $request = $.ajax(params);
$request.then(success);
$request.fail(function (jqXHR, textStatus, errorThrown) {
alert(errorThrown);
});
return $request;
}
The problem is that the error reported is not in XHR format (in order to detect 401 HTTP code) but an error telling "SyntaxError: Unexpected end of JSON input".
When seeing the response using Chrome developer tools, I do see that the response was in XHR format with 401 HTTP code but Select2 transforms it in some way.
Is there a way to solve this?
Regards
Jaime
ajax: {
// ...
error: function (jqXHR, status, error) {
console.log(error + ": " + jqXHR.responseText);
return { results: [] }; // Return dataset to load after error
}
}

react-native-fbsdk not returning email

I have integrated the react-native-fbsdk library and getting user profile info such as name, middle name etc except email
i have tried readPermissions={["email,"public_profile","friends"]}
Then too not getting email
Any help would be appreciated.
Thanks in advance
I'm facing the same issue and it looks like the only workaround is using the LoginManager class provided by react-native-fbsdk.
import {
LoginManager,
} from 'react-native-fbsdk';
const _fbLogin = () => {
LoginManager.logInWithReadPermissions(['public_profile', 'email']).then(
(result) => {
if (result.isCancelled) {
alert('Login cancelled');
} else {
alert('Login success with permissions: ' + JSON.stringify(result));
}
},
(error) => {
alert('Login fail with error: ' + error);
}
);
}
And you can try using that _fbLogin function as an event handler for a custom button. I did not find how to use it with the blue, out of the box facebook Log in button.
Hope it helps!
readPermissions has now been replaced with permissions
<LoginButton
permissions={["email", "user_friends", "public_profile"]}
onLoginFinished={this._onFacebookLoginFinished.bind(this)}
onLogoutFinished={this._onFacebookLogoutFinished.bind(this)}
/>
Once you've completed a login and have an access token, you need to use the Graph API https://github.com/facebook/react-native-fbsdk#graph-api to retrieve data
you can find explaination for it here

jQuery JsTree and JSON error handling

I am using MVC to pass JSON data to JsTree and show a hierarchical view of information.
Everything is working just fine, however, there are times when the user does not have access the the data or for some reason the MVC action throws an exception:
In these cases, the action passes a JSON error message and sets the HttpStatusCode to NotAccepted or InternalServerError.
However the jsTree's sinner keeps spinning and I don't seem to find a way to make it stop and show the error message.
Has anyone solved this issue before? How can one does error handling when using JsTree's JSON data plugin?
UPDATE:
I figured out how to capture the error:
$("#jstree1").jstree({
"json_data": {
"ajax": {
"url": serviceUrl,
"data": function (n) {
return { pid: n.attr ? n.attr("id") : "" };
},
"error": function (x, s, r) { var err = $.parseJSON(x.responseText); if (err!="") { alert(err); } }
}
}
It seems that JsTree does get the MVC http statusCode and the error, now I need to figure out how to tell the JsTree to stop waiting and remove the spinner image!
I am also looking for a good way of showing the error in JsTree, or should I manage the error message outside of it?
I've solved this problem.
Just a note- the code example above for handling ajax call errors is incorrect, please see a complete example below:
$('#YourTree').jstree({
"json_data": {
"ajax": {
"url": "/Controller/Action",
"data": function () {
return { Parameter1: "Value1", Parameter2: "Value2" }
},
"type": "POST",
"dataType": "json",
"error": function (jqXHR, textStatus, errorThrown) { $('#YourTree').html("<h3>There was an error while loading data for this tree</h3><p>" + jqXHR.responseText + "</p>"); }
}
}
});
And in the actual action, you need to set the http response status code to 1 and write the error. e.g.
Response.StatusCode = 1
Response.Write("Error you want to go into jqXHR.responseText here");
Enjoy :)
Maybe you should look into handling this error a layer above the .jstree. Maybe by handling the window.onerror event you can achieve this. In here you could call a function that will rebuild the tree or something? Be sure to include this script as the first one in your page.
<script type="text/javascript">
window.onerror = function(x, s, r){
alert('An error has occurred!')
}
</script>

Resources