Undefined response from meteor method call - meteor

I am calling meteor function which has an api to fetch data from google. But before getting the result it returning from method. I know it is similar to the question Returning value from callback within Meteor.method
But i don't want to use any npm module(future-fiber) to solve this. Is there any similar package in meteor which provide same functionality.

Related

Multiple errors when importing nodemailer in nextjs API

I am trying to have an API endpoint pages/api/sendEmail that uses nodemailer to send an email, but for some reason I get the error Can't resolve 'fs' when I try to use nodemailer with let nodemailer = require('nodemailer'). I have seen multiple posts about this always saying that this is due to the fact that I am trying to execute this in the frontend, but I am doing it in the API. I have also seen posts like this one and tried the fixes by modifying next.config.js, but after all the fixes this new error appeared:
Uncaught TypeError: util__WEBPACK_IMPORTED_MODULE_3__.TextEncoder is not a constructor
What I don't understand here is why can't I use the package in the API, since it is executed on the backend. I have seen multiple tutorials like this one that do the exact same thing.

Error: credentials argument needs to implement signRequest method

I got a question -- I am trying to reuse the response from the ms-rest-nodeauth library. This way everytime I use my tool, I only need to authenticate if the authentication context is not valid.. Whenever I try to use the returned response I get this error
Error: credentials argument needs to implement signRequest method
Anyone got any suggestions?
If not already done then I believe that you would have to double check the code by leveraging the samples provided in this repo. If those samples are not helpful to resolve your error then raising an issue here / here would help you with better response from the repository contributors, etc.
Other references:
ms-rest-nodeauth (azure-sdk-for-js) : Error: credentials argument needs to implement signRequest method
https://github.com/Azure/azure-sdk-for-js/issues/3936

trigger function on firebase deploy functions

Does anyone know if there is an easy way to trigger a function everytime i re-deploy some funciont to firebase?
I have an specific firabase functions which i define inside GCP (this way when i do "firebase deploy" it doesnt re-deploy, unnisntal or touch in any form my current function)
but sometimes i might update this function manually on GCP and i would like to trigger a inner function of its code everytime it happens... is it possible?
ex:
exports.decrementAction = (req, res) => {/*do stuff*/res.status(200).send("ok")};
function auxiliary(){
//to be called on re-deploy
}
Unfortunately, there isn't an easy way for you to trigger a function within a code that is being redeployed. Since this code is only being deployed at the moment, this wouldn't be possible to be done automatically.
The alternative would be to have this function separately from the "root" function in the moment of deploying and use triggers to run this other Cloud Function, when the first is redeployed. This way, it would be possible to run it based in the deployment of the other.
You can get more information on the triggers available for Cloud Functions here: Calling Cloud Functions. With them, you should be able to configure the timing for the execution.
Besides that, it might be worth it to raise a Feature Request for Google's to verify the possibility of adding this in future releases.
Let me know if the information clarified!
I think there exists a manner.
With Pub/Sub you can catch logs from Stackdriver (docs). Those services allow you to store only the logs related to the deployment of a Cloud Function.
The store could be, for instance, Cloud Firestore. As you should know, there is available a trigger for Cloud Firestore events.
Finally, every time an event log related to a function's deployment is generated, it will be stored and triggers a function attached to that event. In the function, you can parse or filter the logs.

In Meteor Methods this.connection is always undefined

I am trying to implement some methods for a DDP API, for use with a C# remote client.
Now, I want to be able to track the connection to implement some type of persistent session, to this end, id hope to be able to use the session id given by DDP on connection, example:
{
"msg": "connected",
"session": "CmnXKZ34aqSnEqscR"
}
After reading the documentation, I see that inside meteor methods, I can access the current connection using "this.connection", however, I always get an undefined "this.connection".
Was it removed? If so, how can i access it now?
PS: I dont want to login as a user and access this.userId, since the app I want to create should not login, but actually just get a document id and do work associated with that, including changes to other collections, but all, regarding ONLY this id, and I dont want to have to include this id every time I call a function, since, this could possibly lead security problems if anyone can just send any id. The app would ideally do a simple login, then associate token details with his "session".
Changing from:
() => { this.connection; }
to:
function() { this.connection; }
solves the problem from me. Based on a comment in the accepted answer.
The C# client on github has a few bugs with it as it doesn't follow the DDP spec exactly. When you send commands to it to connect and run a call, it usually sends the '.call' too soon.
The method does work if you do it this way with this.connection on the server side Meteor method.
You need to make sure you send the method calls after you know that you are actually connected. This is what works at least with Meteor 0.8.2
I was using a file named ".next.js" to force meteor to use the newest unsupported javascript spec using a package.
Somehow this messed it up. Changed back to default javascript and it now works.
Thank you :)
init.coffee
Meteor.startup ->
# client init
if Meteor.isClient
Meteor.call "init"
methods.coffee
Meteor.methods
init: ->
console.log #connection.httpHeaders.host
it's that easy...

Deps.autorun says server function is undefined

I've never took the time/chance to really understand the scope of Deps.autorun... so here I am again with the same problem that had bothered me many times (previously, I always found a workaround and bypass the issue)... anyways, basically, I have a function defined on the server side:
serverFunc = function() {}
and on the client side, I do
Deps.autorun(function() { var test = serverFunc(); }
I get error message say serverFunc is not defined.
Can someone kindly help me understanding why this is happening?
Thanks so much!
Deps.autorun() always runs once, then reruns the function whenever any of the dependencies that are tracked changes. These dependencies usually need to be set up as Meteor reactive data sources. A simple function being undefined on the client and then defined on the server isn't enough to retrigger.
If you want functions defined only on the server to be called from the client, you have to do two things:
On the server, put the function in Meteor.methods
On the client, use Meteor.call
Otherwise, a function defined only on the server does not exist on the client, and calling it on the client will throw an error as calling an undefined function.

Resources