0
I am using MeteorJS technology and trying alerts on success or failure
of meteor call. And alerts not working, unable to recognize the 
problem. And this is a client-side code.

             Template.socialIntFBGoogle.events({
                 'click .socialFb': function(event) {
                     Meteor.loginWithFacebook({}, function(err){
                         if (err) {
                          throw new Meteor.Error("Facebook login failed");
                          }else{
                          alert("Google login");
                          Meteor.call('transfer',function(error, result){
                          if(error){alert(error);} 
                          else{alert("Successful");}                         
                          });

                     FlowRouter.go('/');
                   }
                });
              },
           });

Thanks in Advance!
Rashmi
  • 565
  • 2
  • 7
  • 29
  • 6
    Are you trying to use `alert` on server side? – ghybs Mar 30 '17 at 07:07
  • As an aside, purely a matter of style, why do people do this: `else{}`? If the block is empty just leave the `else` off entirely. – nnnnnn Mar 30 '17 at 07:10
  • @nnnnnn I've never seen anyone do that, I think in this case it was just because of copying code to SO. If anyone **does** do that I agree with you, just leave it out. – George Mar 30 '17 at 07:12
  • @George - I've seen it in production code. I've also seen empty `if` blocks with non-empty `else` blocks. (But even for SO it would've been as easy to delete the whole thing as delete the contents of the block.) – nnnnnn Mar 30 '17 at 07:22
  • 1
    Most likely, you're trying to use `alert` on server side. Please replace `alert` with `console.log` and see whether you get the log on Browser console (means Client side) or Terminal (means Server side). `console.log` is valid on both client and server side. – Sangharsh Mar 30 '17 at 07:45
  • The error log quoted in the question is clearly a server side log. – Quentin Mar 30 '17 at 07:48
  • Yes it is a server side alert. I have replaced it with console.log and of-course it is not throwing errors though. But question is even though I am trying alert on client side. I am not getting any alert message , and I am unable to recognize why? – Rashmi Mar 30 '17 at 07:54
  • @Rashmi — Since your attempts are resulting in the server throwing an error message the reason is that when you tried to write client side code, you missed and wrote it in the server side code instead. – Quentin Mar 30 '17 at 07:55
  • Now I did it like this :- if(existingAddressCheck){console.log("Google login");}else{//some code} , and it is not throwing any error @cmd. At client side My piece of code looks like this : Meteor.call('transferUserDataFromServicesToProfile', "facebook", (error, result) => { if(error){ console.log(error); //If there is any error, will get error here }else{ alert("Transfer of User Data From Services To Profile Successful!"); } }); But still this alert not working. – Rashmi Mar 30 '17 at 08:45

1 Answers1

0

For logging purposes you should not using alert instead replace your alert calls with:

console.log("your message");

After that you can review, the output in your Web browser Dev tools.

fxdapokalypse
  • 21
  • 1
  • 3