Insert server data after API call back


#1

Hello, I am new to meteor. I am using meteor methods for API call. I want to display the sever received data on browser. I am able to log the data on client side. But I am not able to insert it to the database.


Meteor.methods({
‘geoJsonForIpSecond’:async function() {
if (Meteor.isServer) {
return new Promise(function (resolve, reject) {

HTTP.call( ‘POST’,‘http://apils.seosera.com/user/login’, {
params: {
“email”: "mytest@gmail.com",
“password”: “kite12345”
}
}, function( error, res ) {
if ( error ) {
} else {
var email = res.data.result.data.user_data.email;
console.log(email);
Mymongo.insert({
email,
createdAt: new Date(), // current time
owner: Meteor.userId(),
username: Meteor.user().username,
});
resolve (res.data.result.data.user_data.email);
}
});
});
}
}
});

Meteor.call(‘geoJsonForIpSecond’, function(error, response){
var myEjosnData = EJSON.stringify(response);
var email = response.user_data.email;
console.log(email);

I want to insert the email to my database. But blank is inserted.
Thank You


#2

Please wrap your code blocks in triple backticks:

```
your
code
here
```

Also, change that password you’ve used in your code. That may cause offense.