0

I am working on an EOS dApp that is listing dogs (it could be other items) and displaying them on an HTML page. The dApp has a function in its JS file to add dogs.

This dApp is working with nodeos up and running, a Python server up and running, and Scatter.

In my HTML page, although I can see some elements such as the textbox and the button to add dogs, the list of dogs is not diplayed. It should come inside my <ul id="doglist"></>

Instead, I am getting an error in my console:

Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0

asyncToGenerator.js:6

My asyncToGenerator.js file reads as follows:

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  try {
    var info = gen[key](arg);
    var value = info.value;
  } catch (error) {
    reject(error);
    return;
  }

  if (info.done) {
    resolve(value);
  } else {
    Promise.resolve(value).then(_next, _throw);
  }
}

function _asyncToGenerator(fn) {
  return function () {
    var self = this,
        args = arguments;
    return new Promise(function (resolve, reject) {
      var gen = fn.apply(self, args);

      function _next(value) {
        asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
      }

      function _throw(err) {
        asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
      }

      _next(undefined);
    });
  };
}

module.exports = _asyncToGenerator;

It seems the reject(error); line in the first function is causing an issue.

If you need to see my main.js file that is part of my front end, I can post it here.

Thank you for your assistance!

0

TLDR That unexpected token < is a strong clue that the response was HTML instead of JSON. While you expected to get JSON

  • Yes, it should be the issue or part of the issue, but what do I need to do to correct my code to make it work? If you need me to paste my main.js code here for clarification, please let me know and I will do it. – vinchik Oct 4 '20 at 10:35

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.