External calls made to API in C # with meteor js and usb device

118 views Asked by At

I have created a example of project app device from meteor. Inside my code I created side server have created a CRUD with C # web api 2.0. While meteor side I created on method inside main.js on the SERVER folder, where I'm going to point to the web api:

addStudent:function(FirstName,LastName,Email,Address){ 
   Toast.info(result);
    this.unblock();
    var result = Meteor.http.call("POST","",
                   {
                    data:{
                            "FirstName": FirstName,
                            "LastName" : LastName,
                            "Email": Email,
                            "Address":Address
                        }
                    }
                );
        //Toast.info(result);
    return result;
},`

and inside main.js I called the method in the client:

Template.createStudent.events({

    'click #btnCreate':function(events){            
        events.preventDefault();
        var Firstname='pippo';
        var Lastname='pluto';
        var Email='[email protected]';
        var Address='via polo nord';
        setTimeout(function() { 
            Meteor.call("addStudent",Firstname,Lastname,Email,Address, function(error, result) {

                if (error) {
                    Toast.info("Client:" + error);
                    alert("Oops!!! Something went wrong!");
                } 
                else {
                    Toast.info("Client:" + result);
                    Session.set('tx', result);
                }    
            });   
        });
    }
});

When I go to throw ("meteor run Android-device") the project concerned, and connect the usb of my phone, he does not call the service, but if I run it on the browser ("localhost: 3000"), everything works fine.

P.S.: In addition I have also enabled the enableCors on side Api .NET

Could you help me understand why?

Thank you

0

There are 0 answers