Get post.length data and use it in other function

Hi, I have two pieces of code I want to connect togheter.

The first one is a simple hashtag counter. The second one is an node.js osc library.

I want to get the data from the counter and send it with osc to sonic pi.
The data is in form of a posts.length and that is the value to send via osc.

At the moment I’m unable to figure out how to pass the counter data (posts.length) and send it to the osc send function.

Any help is greatly appreciated

(async() => {
    console.log("Hashtag Script")
    let ig = await login();

    async function hashtag(ig) {
        let hashtag = "cat";
        console.log("\n -- Hashtag counter --\n".bold.underline);

        let posts = await recentHashtagList(ig, hashtag);
        console.log("Posts received with hashtag: ".cyan + *posts.length*);

        oscPort.on("ready", function() {
                address: "/osc*/play/note",
                args: [{
                    type: "f",
                    value: *posts.length*
        let promises = [];
        for (let i = 0; i < posts.length; i++) {
            let post = posts[i];

        Promise.all(promises).then(function() {
    // every 10 minutes do hashtag job
    schedule.scheduleJob('*/10 * * * *', async function() { await hashtag(ig) });


What part doesn’t work?
Please add a try/catch block so we can understand the error you are getting.

I’m not getting an error but I also do not get a an incoming message in the osc listening software.

EDIT: I did get an error report.

(node:29016) UnhandledPromiseRejectionWarning: ReferenceError: oscPort is not defined
    at hashtag (/Users/*****js:25:9)
    at async Job.job (/Users/***/:44:61)
(node:29016) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see (rejection id: 238)

Nobody any idea to get data from an anonymous async function in to another function?

To get data from a function you have to return it.
You can use Promise.resolve for async operation or the await/async syntactic sugar.

 Promise.all(promises).then(function(data) {
            return data;
     conole.log("Error:" , e);

or inside async/await function

try {
   let data = await Promise.all(promisses);

   return data;

} catch(e) {
  console.log("Error:" , e);

To resolve the error you had before read the error message and correct it.