You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This methos only pass path attributes. I created the angular counterpart using lb-ng and when I execute this method from javascript I obtain this error:
MyModel.sale({customerId: customerId,amount: price}).$promise.then(function(value,responseHeaders){$.bigBox({title: "Plan Selected",content: "Your plan has been selected successfully",color: "#739E73",//timeout: 8000,icon: "fa fa-check",number: "1"});},function(httpResponse){varerror=httpResponse.data.error;console.log('Error login '+error.status+": "+error.message);});
POST http://www.tachoexplorer.com:3000/services/rest/Braintrees/customers/amount 404 (Not Found)
The problem is that the lb-service not inject my attributes in the REST request. If use curl tool from shell the result is ok, so the problem is from client side.
If redesign my webservice like this, adding a stuff attribute on the body
MyModel.remoteMethod('sale',{description: "a model method example with body attributes",accepts: [{arg: 'customerId',description: 'Customer Id',type: 'any',required: true,http: {source: 'path'}},{arg: 'amount',description: 'Amount',type: 'any',required: true,http: {source: 'path'}},{arg: 'stuf',description: 'Stuff attribute',type: 'object',required: true,http: {source: 'body'}}],returns: {arg: 'result',type: 'object',root: true},http: {verb: 'post',path: '/customers/:customerId/amount/:amount'}});
And create again the counterpart in angular and called it again, now not exist any problem
MyModel.sale({customerId: customerId,amount: price},{stuff: {}}).$promise.then(function(value,responseHeaders){$.bigBox({title: "Plan Selected",content: "Your plan has been selected successfully",color: "#739E73",//timeout: 8000,icon: "fa fa-check",number: "1"});},function(httpResponse){varerror=httpResponse.data.error;console.log('Error login '+error.status+": "+error.message);});
The problem seems to be than I need to add any body attribute in my method to runs ok, meaby it
Also if a reconfigure again my method model using GET and not POST the result is ok, in that case with any stuff body attribute.
Could be a bug?? or I am making something wrong.
Regards
The text was updated successfully, but these errors were encountered:
Hey @masalinas, that makes absolutely no sense to me that GET would work and POST wouldn't... looks like you've found a bug! Just to make sure, I'm going to ask a huge favor of you. Could you please fork a loopback-sandbox and re-create your issue? Make sure your update the package.json please!
There's a chance that something is going wrong somewhere else in your code so in order to verify that this is a bug, the best thing to do is reproduce in a new sandbox. Even if it isn't a bug, if you can reproduce, we can probably figure out what to fix!
When you have a POST endpoint and invoke it with a single parameter, this parameter is interpreted by Angular.js as "postData".
The solution is to invoke you resource method with an empty postData body:
MyModel.sale({customerId: customerId,amount: price},{}).$promise// etc.
Since this is not the first time I noticed this problem, I think it would be great if we could modify the ngdoc generated by lb-ng to include a note for the users and also update our documentation at loopback.io (link).
I have the next problem:
First I have a method model defines like this:
This methos only pass path attributes. I created the angular counterpart using lb-ng and when I execute this method from javascript I obtain this error:
The problem is that the lb-service not inject my attributes in the REST request. If use curl tool from shell the result is ok, so the problem is from client side.
If redesign my webservice like this, adding a stuff attribute on the body
And create again the counterpart in angular and called it again, now not exist any problem
The problem seems to be than I need to add any body attribute in my method to runs ok, meaby it
Also if a reconfigure again my method model using GET and not POST the result is ok, in that case with any stuff body attribute.
Could be a bug?? or I am making something wrong.
Regards
The text was updated successfully, but these errors were encountered: