Jump to content

Run async JS file and wait for response


Lachero

Recommended Posts

Hello All!

I'm curious if this is possible to do the followings:

 

I created a JS file script on my computer, I'm curious if that is possible to run this file using node through Alfred workflows.

If yes, please let me know how.

 

I'm also curious if alfred can run this code in the file and wait for a response and then I will use the response from the function on a POST notification step.

 

Thanks!

Link to comment

Welcome @Lachero,

 

6 hours ago, Lachero said:

I'm curious if that is possible to run this file using node through Alfred workflows.

If yes, please let me know how.

 

It is, the same way you’d do it in a shell. Call it in a Run Script Action and you’re mostly done. Alfred doesn’t consider your shell’s environment, which means it will have no idea of the node installation. Before you call the script, you’ll need to set PATH to include wherever node is installed, or it may suffice to call it with node’s full path (e.g. /usr/local/bin/node your-script.js).

 

6 hours ago, Lachero said:

I'm also curious if alfred can run this code in the file and wait for a response and then I will use the response from the function on a POST notification step.

 

Alfred will wait just like your shell would (or not). You’ll capture the output much in the same way you’d do it there, and whatever you pass from it to a Post Notification Output is what will be shown.

 

In sum, get it to work correctly in the Terminal and it will be easy to make it work in Alfred.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...