node-oanda icon indicating copy to clipboard operation
node-oanda copied to clipboard

modifyExistingTrade - TypeError: Cannot read property 'params' of undefined

Open rockscripts opened this issue 7 years ago • 1 comments

Good day and thanks for this wrapper. i'm trying to modify a trade but i'm getting error message executing this: var requestTrade = apiV2.trades.modifyExistingTrade("my acount id","75",{takeProfit:{price:"1.19900"}});

ERROR data = this.requestUrlFormatter.createParamString(this.urlFormmater.params); TypeError: Cannot read property 'params' of undefined

It sets params in setParameters urlFormatter it happens on line 92:api_core.js

issue

could you do an example calling this method with dummy data? Thank you in advance for your help.

rockscripts avatar May 15 '18 02:05 rockscripts

Hey rockscripts. It appears as though no one else that's used this library (including myself) has ever tried to do POST/PUT requests, because the code is actually unfinished! createParamString is not a function that exists on the requestUrlFormatter, and this.urlFormmater is also undefined. The errors should be nothing to do with your code but with the library itself.

What I was attempting to do there is to parse an object and convert it into a form data string like

key1=value1&key2=value2

It looks like in the V2 Oanda docs, they use JSON data rather than form data, so this step should no longer be necessary. The request may need changes to the way the data is encoded, or at least stringify the data object inside.

I'm not really actively developing this too much, so feel free to make a pull request, I will most likely merge it in, as long as it works fine. Also, I will be starting on a V2 of this shortly, which will effectively be a complete rewrite for modern versions of Node.

Cheers

flagpoonage avatar May 16 '18 01:05 flagpoonage