Skip to content

client.read() returns string rather than JS object #1

@Yukigamine

Description

@Yukigamine

Using Sheetdb for the first time and it seems very strange to me that client.read() returns a string rather than a JS object (since it is already in JSON).

Parsing is as simple as json = JSON.parse(data), but it still seems odd that the module wouldn't return the data as an object since in order to do anything with the data you have to parse it...

Code to reproduce

client.read({})
.then(function(data) {
    console.log('Original object: ' + data[0])
    json = JSON.parse(data)
    console.log('JSON Object: ' + json[0]);
  },
function(err){
    console.log(err);
});

Output

Original object: [
JSON Data: {
  Player: 'Smith',
  Score: '41',
  Comment: ''
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions