Git Product home page Git Product logo

Comments (4)

sv2 avatar sv2 commented on May 29, 2024 1

This is addressed by commenting out ctx.res.writeHead(200) in swsInterfaceKoa.js:

async function processGetStats(ctx) {
    //ctx.res.writeHead(200)
    var query = {};
    for (let key in ctx.request.query) {
        query['fields'] = ctx.request.query[key]
    };
    let content = swsProcessorkoa.getStats(query);
    // console.log(content)
    // content =
    ctx.body = content;
}

I think writeHead finalizes headers, and so Content-Type can't be added after it ...

Good Luck !

from swagger-stats.

sv2 avatar sv2 commented on May 29, 2024

Wow, first of all - thank you for adopting it for Koa!

Looks like the issue is because in UI response to /stats request is received as text, not JSON
In SWSUI.prototype.refreshStats

  var jqxhr = $.ajax(getdataReq)
            .done(function(msg) {
                // Login attempt successfull
                var xswsauth = jqxhr.getResponseHeader('x-sws-authenticated');
                if ((xswsauth !== undefined) && xswsauth && (xswsauth == 'true')) {
                    $('.sws-logout-ctrls').show();
                }

                // process received data as needed
                that.processStatsData(getdataDef, msg);

There msg is text, not object. As a result, further processing fails.

from swagger-stats.

sv2 avatar sv2 commented on May 29, 2024

Looks like when Koa returns response for /stats request, headers Content-Length and Content-Type: application/json; charset=utf-8 are not set

from swagger-stats.

dduo518 avatar dduo518 commented on May 29, 2024

@sv2 thank you very much ! that all right now !

from swagger-stats.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.