CornerCouch icon indicating copy to clipboard operation
CornerCouch copied to clipboard

.getDoc() isn't working

Open sangel10 opened this issue 11 years ago • 1 comments

I get the following error when I try to call db_obj.getDoc(id):

Uncaught SyntaxError: Unexpected token :

I am able to get the expected document object if I create a new document using .newDoc(), but then if I take that object's _id and use it as the argument for .getDoc() then I get the same error.

doc = database.newDoc();
doc.save();

here is my code

$scope.server = server = cornercouch("http://127.0.0.1:5984");
    database = $scope.server.getDB("rbma_articles");
    console.log("database: ", database)

    $scope.getDoc = function() {
        //hardcoded ID
        id = "8760e498a7d8e963187653179000e65f"
        doc = database.getDoc(id)
    }

note: I am using globals so I can access the objects from the console.

Has anyone else run into this issue/is there something I'm doing wrong here or is this a bug?

sangel10 avatar Oct 24 '14 14:10 sangel10

This happens when cornercouch expects to get JSON-P back from the server but instead gets plain JSON. I solved this by adding an extra "GET" parameter to the cornercouch() function call, like this:

cornercouch("http://127.0.0.1:5984", "GET");

philippbosch avatar Nov 06 '14 13:11 philippbosch