These are chat archives for reactioncommerce/reaction

29th
Aug 2018
Gurpanthport
@Gurpanthport
Aug 29 2018 00:08
Will I be able to upload an image by a form instead of putting the image physically in the directory with the _id name?
rohit-elevar
@rohit-elevar
Aug 29 2018 14:29
I realised the error. I am unable to use Meteor.userId() since the function it is being called in is neither a meteor method nor a publication. Its a WebApp.connectHandlers function.
Is there anyway to set the userId, which i can pass to the WebApp.connectHandlers, somewhere, so that meteor recognises it in the rest of the reaction app for that request
Abhishek
@thegtagamer
Aug 29 2018 14:37
I tried to create a custom Hook Plugin to transmit some data when a product is being added...But i ended up getting this exception..pls help
Exception while invoking method 'cart/addToCart' TypeError: Cannot set property 'tags' of undefined
    at MethodInvocation.MethodHooks.after.options (imports/plugins/custom/my-hooks/server/orders.js:253:3)
    at _each (imports/plugins/core/core/server/method-hooks.js:112:36)
    at arrayEach (/Users/abhi/Desktop/asort-rc/node_modules/lodash/_arrayEach.js:15:9)
    at forEach (/Users/abhi/Desktop/asort-rc/node_modules/lodash/forEach.js:38:10)
    at MethodInvocation.MethodHooks._wrappers.(anonymous function) (imports/plugins/core/core/server/method-hooks.js:111:5)
    at currentArgumentChecker.withValue (packages/check/match.js:118:15)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1189:12)
    at Object._failIfArgumentsAreNotAllChecked (packages/check/match.js:116:43)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1764:18)
    at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1189:12)
    at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1189:12)
    at Promise (packages/ddp-server/livedata_server.js:715:46)
    at new Promise (<anonymous>)
    at Session.method (packages/ddp-server/livedata_server.js:689:23)
Abhishek
@thegtagamer
Aug 29 2018 14:43
MethodHooks.after("cart/addToCart", (options) => {

  const proId = options.arguments[0];
  const product = Products.findOne(proId);
  let tags;
  if (product) {
    if (_.isArray(product.hashtags)) {
      tags = _.map(product.hashtags, function(id) {
        return Tags.findOne(id);
      });

    }
  }
  product.tags=tags;
  HTTP.post(URL_TO_EXT_SOURCE {
    data: product
  }, (error, response) => {
    console.log("Response: "+response);
  });

});

I tried to modify

if (_.isArray(product.hashtags)) {
      tags = _.map(product.hashtags, function(id) {
        return Tags.findOne(id);
      });

    }

to

if (_.isArray(product.hashtags)) {
      tags = Tags.find({ _id: { $in: product.hashtags } }).fetch();
    }

but no luck..still getting the same thing

Patrick Newell
@pnewell4_twitter
Aug 29 2018 16:11
@thegtagamer I think it's telling you that product is undefined. you have an if (product) guard in there, but later you assume that product is defined... product.tags = tags