Coder Social home page Coder Social logo

info result about nodemw HOT 8 CLOSED

vid avatar vid commented on June 3, 2024
info result

from nodemw.

Comments (8)

macbre avatar macbre commented on June 3, 2024

Take a look at https://github.com/macbre/nodemw/blob/master/lib/api.js#L170

Callback passed to this.api.call is provided with a following parameters:

callback(info, next, data);

data contains "raw" data returned by API. That's the one with data you're interested to get from the server.

from nodemw.

vid avatar vid commented on June 3, 2024

I'm sorry that I don't quite understand this, maybe it's because of my head cold. =) Does one of the other API calls provide an example?

I did implement a solution for this in my own code.

    getAsk: function(params, callback) {
        params.action = 'ask';
        params.resultKW = 'query';

        this.api.call(params).then(function(res) {
            callback && callback(res);
        });
    },

then in api.php:

                info = data && data[params.resultKW || actionName];

from nodemw.

macbre avatar macbre commented on June 3, 2024

If you're using a promise pattern, you should do the following:

    function(params, callback) {
        params.action = 'ask';
        params.resultKW = 'query';

        this.api.call(params).then(function(res) {
            callback && callback(res.data && res.data.results);
        });
    }

https://github.com/macbre/nodemw/blob/master/lib/api.js#L182

from nodemw.

vid avatar vid commented on June 3, 2024

is code as intended?

https://github.com/macbre/nodemw/blob/master/lib/api.js#L171

shouldn't it be something like:

data[actionName] || data ?

otherwise it doesn't seem like the following block will get executed if the actionName doesn't match the return key.

https://github.com/macbre/nodemw/blob/master/lib/api.js#L178-L187

from nodemw.

macbre avatar macbre commented on June 3, 2024

Yeah, good point!

An if block at line 178 should be changed to allow that kind of responses to pass.

from nodemw.

vid avatar vid commented on June 3, 2024

is this a change you can make? I don't quite understand the intent of this section of code (if there's going to be an else to pass it through anyway, why make an if at all). If you can do that, I can commit some additional actions.

I would like to add some code supporting emerging SMW javascript support, would this be ok to add to nodemw or can it be made modular?

thanks!

from nodemw.

macbre avatar macbre commented on June 3, 2024

Sure, I'll make this change.

Then, fell free to add SMW specific actions :)

from nodemw.

macbre avatar macbre commented on June 3, 2024

Done in f12f420

from nodemw.

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.