Comments (8)
It looks like you got upgraded to version 2.0
, which eliminates done
in the interest of being compatible with ES6 promises. You can:
- replace
done
withthen
or.. - depend on
deanius:[email protected]
in.meteor/packages
That should fix at least one of your errors, let me know how it goes after.
from meteor-promise.
Thanks for the info, but even without adding the done method at all I still can't get the promises to work. I think I simply don't understand where/how to create the correct functions.
In your example in the readme, you create a createCustomer
function that returns a promise to createCustomer
. Then you call that function with Meteor.promise("createCustomer")
? Which createCustomer function is it referring to? It looks like Meteor.promise("function")
should look for a Meteor.methods
function, but you created a generic one with the same name then promised it?
Following the stripe example, I have two meteor methods stripeCreateCustomer
and stripeCreateSubscription
which uses the fibers/future stuff. How should I lay out my Meteor.promise
to first call stripeCreateCustomer
and then stripeCreateSubsription
?
Why is the promise method in quotes but the then method not, but you create both as functions in the same context?
from meteor-promise.
I completely updated the README, correcting errors and simplifying.
Particularly I went to the style where the functions inside of then
are unnamed. Declaring functions to use as promise steps, prior to using them is an optional, advanced thing. I see the confusion it was causing, as they were named similar to the ones on the server, yet doing slightly different things.
Also, in your case I want to point out that you don't typically want to use Promises on the server, in the Meteor.methods
call, you use them only in the browser to sequence and error-handle the Meteor.call
that you make.
Does that clear it up now ?
from meteor-promise.
I ended up dumping most of the meteor chef's code. It was simply too confusing for me to follow, he was calling a server method that then called two more server methods, which used futures. Combining all the futures + promises + callbacks was too confusing for my simple brain.
Also the stripe API changed and you can now create the customer and subscription at the same time.
I ended up with this, seems like I got it right based on your last update!
client/userProfile.js
createSubscription(){
Stripe.setPublishableKey("KEY")
// update to real content, just using placeholder CC number for now
Stripe.card.createToken({
number: "4242424242424242",
cvc: "123",
exp_month: "12",
exp_year: "17",
}, (status, response) => {
stripeToken = response.id;
Meteor.promise("createSubscription", stripeToken, this.user)
.then( (customer) => {
return Meteor.promise("updateUser", customer, this.user)
})
.done( () => {
console.log("done?");
})
});
},
from meteor-promise.
Nice. And ES6 too :)
from meteor-promise.
Actually, I am now getting a new error: Uncaught TypeError: undefined is not a function
which points to my catch function:
Meteor.promise("createSubscription", stripeToken, this.props.user)
.then( (customer) => {
return Meteor.promise("updateUser", customer, this.props.user)
})
.then( () => {
console.log("done i think");
})
.catch( (error) => {
console.log("error! : ", error);
})
});
Do you see anything glaringly obvious? I am trying to trigger the error state by signing up a customer for a plan that doesn't exist, but instead it goes through and throws that error.
from meteor-promise.
I don't see anything - if you look at the tests: https://github.com/chicagogrooves/deanius-meteor-promise/blob/master/tests/chaining-tests.next.js , they should show some passing examples with catch
.
You can run them locally by cloning this repo, and doing meteor test-packages ./
then browsing to the address it shows.. It might be easier to try some examples outside of the stripe environment, just a thought.
from meteor-promise.
If you think you found a bug, reopen this and let's look at a PR with a failing test case (it's really simple).
from meteor-promise.
Related Issues (20)
- Problem with "loanding" text, when get data from collection on Meteor.methods()? HOT 2
- Could I return array form Meteor.methods()? HOT 1
- Replacing to okgrow:promise should we update our current promisses? HOT 7
- Promise.all like for Meteor.subscribe - #readyPromise() HOT 5
- Provide HTTP.callPromise on the server? HOT 4
- okgrow vs deanius meteor-promise? HOT 2
- Feature request: Meteor.applyPromise HOT 1
- Support for IE8 ? HOT 1
- Getting "TypeError: Object [object Object] has no method 'callPromise'" HOT 5
- Wrap the collection methods (insert,update,elete)?
- Getting errors running tests in Meteor 1.3-rc.2 HOT 3
- Demo / Docs Is Down HOT 4
- Test
- cosmos:browserify dependency HOT 3
- Omits query fields in data-loading method HOT 1
- not compatable with Meteor 1.6
- DevTools failed to parse SourceMap
- publish latest? HOT 1
- This package is still maintenance?
- How to Synchronous call on the Server (return result)?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-promise.