Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Issue #13: less "strict" error checking in api.js + SMW example

  • Loading branch information...
commit f12f4206da39426f68a140adf6b19b3291d55c47 1 parent af6cd6f
@macbre authored
Showing with 21 additions and 2 deletions.
  1. +19 −0 examples/smw.js
  2. +2 −2 lib/api.js
View
19 examples/smw.js
@@ -0,0 +1,19 @@
+/**
+ * Example script of Semantic MediaWiki integration
+ *
+ * @see http://semantic-mediawiki.org/wiki/Ask_API
+ */
+
+var bot = require('../lib/bot').bot,
+ client = new bot({
+ server: 'semantic-mediawiki.org',
+ path: '/w'
+ }),
+ params = {
+ action: 'ask',
+ query: '[[Modification date::+]]|?Modification date|sort=Modification date|order=desc'
+ };
+
+client.api.call(params, function(info, next, data) {
+ console.log(data && data.query && data.query.results);
+});
View
4 lib/api.js
@@ -175,7 +175,7 @@
throw 'Error parsing JSON response: ' + res.body;
}
- if (info) {
+ if (data && !data.error) {
if (typeof callback === 'function') {
callback && callback(info, next, data);
}
@@ -185,7 +185,7 @@
data: data
});
}
- else if (data.error) {
+ else {
throw 'Error returned by API: ' + data.error.info;
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.