dharmaprotocol / dharma.js

DEPRECATED: Javascript Developer library for interacting with Dharma Protocol
https://dharma.io
MIT License
57 stars 24 forks source link

Vue.js await is a reserved word #284

Closed achiko closed 6 years ago

achiko commented 6 years ago

Is this Vue.js issue? is Dharmajs compatible with Vue ?

25 | methods: { 26 | createLoanRequest: function() {

27 | const loanRequest = await LoanRequest.create(dharma, { | ^ 28 | principalAmount: 5, 29 | principalToken: "WETH", ....

rahulrumalla commented 6 years ago

Fellow vuejs-er here. What is the issue/error that you're actually seeing btw?

graemecode commented 6 years ago

@achiko , @rahulrumalla -- could you give me a little more context? Are you seeing this when you try to create a loan request? In that case, you could use:

LoanRequest.create(dharma, {
  ...loanOptions,
}).then((loanRequest) => {
  // continue here...
});
rahulrumalla commented 6 years ago

I'd guess this is a misleading error by IDE plugin. I remember this message from when I missed the 'async' keyword on the function.

graemecode commented 6 years ago

Yes, you definitely would need to have async on the function to use await! Like so:

(async (input) => {
  await doSomethingAsync(input);
})();

Closing for now, let me know if you still think this is a problem. Good luck!

achiko commented 6 years ago

Sorry for a late reply I have just pushed repo: https://github.com/achiko/vue-dharma Please look at https://github.com/achiko/vue-dharma/blob/master/src/components/Loanrequest.vue

I have implemented the Promis eversion : https://github.com/achiko/vue-dharma/blob/master/src/components/Loanrequest.vue#L43

And Async Await version : https://github.com/achiko/vue-dharma/blob/master/src/components/Loanrequest.vue#L63

Now I'm getting the following error:

xml-http-request.js?37da:91 Uncaught (in promise) TypeError: Cannot read property 'node' of undefined at new XMLHttpRequest (xml-http-request.js?37da:91) at HttpProvider.prepareRequest (httpprovider.js?f85f:61) at HttpProvider.sendAsync (httpprovider.js?f85f:116) at RequestManager.sendAsync (requestmanager.js?111b:80) at Object.send (method.js?7c38:141) at eval (index.js?10a5:46) at new Promise () at new F (_export.js?63b6:36) at eval (index.js?10a5:28) at BlockchainAPI.eval (blockchain_api.js?fc5b:199)