Coder Social home page Coder Social logo

Comments (4)

poetsmeniet avatar poetsmeniet commented on June 14, 2024 1

What happens when you use Meteor.callAsync instead?

Yes, that does work. So simple :D

from meteor.

bmartin1134 avatar bmartin1134 commented on June 14, 2024

im not super good but shouldn't the 'function' be 'async function'?

Otherwise what happens when:


  'parameters.upsert': async function(orgId, parametersArr) {
  console.log('upsert params (orgId: ', orgId, '): ', parametersArr);
   try {
   const result =  await Parameters.upsertAsync({orgId: orgId}, {
    createdAt: new Date(),
    orgId: orgId,
    parametersArr: parametersArr
  }) 
    console.log('Upsert operation successful:', result);
    return result;
  } catch {
    console.error('Error during upsert operation:', error);
    throw error; 
  };
return this.ready()
}

from meteor.

poetsmeniet avatar poetsmeniet commented on June 14, 2024

When I make it more simple, like this:

  'parameters.upsert': async function(orgId, parametersArr){
    console.log('upsert params (orgId: ',orgId,'): ', parametersArr);
    const res = await Parameters.upsertAsync({orgId: orgId},
      {
        createdAt: new Date(),
        orgId: orgId,
        parametersArr: parametersArr
      }
    );
    return res;
  }
  await Meteor.call('parameters.upsert', 1, paramArr, (e, res) =>{
     if(res) handleClose(1);
     console.log('paramters.upsert came back: e: ', e, ' and res: ', res);
   });

Console output after first page load:
paramters.upsert came back: e: undefined and res:
Object { numberAffected: 1 }
​numberAffected: 1
​: Object { … }

The second time I call the method, this is console output:
paramters.upsert came back: e: undefined and res:
Promise { : "pending" }
​: "fulfilled"
​: Object { numberAffected: 1 }
​: Promise.prototype { done: done(onFulfilled, onRejected), … }

from meteor.

jamauro avatar jamauro commented on June 14, 2024

What happens when you use Meteor.callAsync instead?

from meteor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.