0

The code given below is my nodejs code forunlocking my wallet name "seek".I got this API from eos developers portal,but don't know how to pass input data(wallet name and password) into it.Please help me.

var request = require("request");
var s ="seek"
payload = [s,"PW5HrGdY9zSiKYB6462dcKfpHZYN3eYSCkER2ZMzTiZjQpxKXh6B4"]
var bi =JSON.parse(payload)
var options = { method: 'POST',
url: 'http://127.0.0.1:8888/v1/wallet/unlock',
headers: { 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8' },body:bi };

request(options, function (error, response, body) {
if (error) throw new Error(error);

console.log(body);
});

The wallet name and password is given in the payload variable.When i run the following code i get this error

undefined:1 seek,PW5HrGdY9zSiKYB6462dcKfpHZYN3eYSCkER2ZMzTiZjQpxKXh6B4 ^

SyntaxError: Unexpected token s in JSON at position 0 at JSON.parse () at Object. (/home/cybrosys/Desktop/experience_project/node2.js:4:14) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Function.Module.runMain (module.js:693:10) at startup (bootstrap_node.js:188:16) at bootstrap_node.js:609:3 [nodemon] app crashed - waiting for file changes before starting...

  • Try, payload = "{"seek","PW5HrGdY9zSiKYB6462dcKfpHZYN3eYSCkER2ZMzTiZjQpxKXh6B4"}" – Muhzin Apr 25 at 11:15
1

The error states that your JSON is invalid. You just need to pass '["WALLET_NAME", "YOUR_WALLET_PASSWORD"]' as body string and that should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.