Error parsing JSON from getData()

Moved from GitHub dgraph-js/43

Posted by aryzing:

The code I’m running looks like

  const schema = `
    name: string @index(fulltext) .
    email: string @index(exact) .
  const op = new dgraph.Operation();
  const result = await dgraphClient.alter(op);
  return result.getData();

However, the getData() call is reporting a JSON parse error:

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Payload.getData (/home/aryzing/workspace/anccre-server/node_modules/dgraph-js/lib/types.js:30:21)

aryzing commented :

Just ran result.getData_asB64() and it produced an empty string, so perhaps the issue is that getData() is not checking whether it’s receiving an empty string.