Comments (8)
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.
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.
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.
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.
Yeah, good point!
An if block at line 178 should be changed to allow that kind of responses to pass.
from nodemw.
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.
Sure, I'll make this change.
Then, fell free to add SMW specific actions :)
from nodemw.
Done in f12f420
from nodemw.
Related Issues (20)
- [0.11.0 Regression] Edits fail but claim success (err = null) HOT 3
- Support namespaces in getPagesByPrefix
- Allow to enumerate/include redirects HOT 3
- Replace jshint with eslint HOT 3
- Planning a release to NPM? HOT 1
- API Errors don't include the original response
- getArticle not working with special characters in title HOT 4
- TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string HOT 1
- SVG upload
- Typescript Types HOT 4
- Dont request new edit token each edit call AND prevent SCRF error
- Next parameter in client.api.call, how to use?
- How to pass parameters to the bot.parse call? HOT 1
- Replace the deprecated 'request' package HOT 2
- Add a command-line module
- CSRF token should be sent as last parameter in request payload
- Add a page edit integration test
- Update Fandom videos upload
- Introduce WikiData client
- `username`, `password`, and `domain` is missing on `BotOptions` type definition. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodemw.