tags:

views:

30

answers:

1

Hi,

I am trying to create a list in CouchDB 0.11 which responds with some html, I am having problems getting CouchDB to set the correct header, whatever I try, I just get an application/json response header. Here is my list function.

function(head, req) {

    var rows = [];
    var row;

    while(row = getRow()) {
        rows.push(row);
    }

    rows.sort(function(a, b) {
        return (Date.parse(a['value']['last_logtime']) - Date.parse(b['value']['last_logtime']));
    });

    provides("html", function() {
        var content = "<html><head><title>foobar</title></head><body>";
        for(var i in rows) {
            content = content + rows[i]['value']['last_logtime']+"<br/>";
        }
        content = content + "</body></html>";
        return content;
    });

}

Any suggestions what I am doing wrong?

+2  A: 

well actually figured it out myself.

the getRow() stuff needs to be inside the provides function :)

SuneKibs