Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError is thrown when attempting to post to mediawiki #5

Open
ghost opened this issue Jan 28, 2015 · 2 comments · May be fixed by #7
Open

TypeError is thrown when attempting to post to mediawiki #5

ghost opened this issue Jan 28, 2015 · 2 comments · May be fixed by #7

Comments

@ghost
Copy link

ghost commented Jan 28, 2015

When I try this:

var MediaWiki = require('mediawiki');

var bot = new MediaWiki.Bot({
    endpoint: "https://en.wikipedia.org/w/api.php",
    rate: 60e3 / 10,
    userAgent: "ExampleBot <https://en.wiktionary.org/wiki/User:Example>",
    byeline: "(example bot edit)"
});

bot.login('my_username', 'my_password').complete(function (username) {
    console.log(['Username:', username].join(' '));

    bot.edit('User:My_Page', 'Testing via API', 'This is a test.')
        .complete(function (title, revision, date) {
            console.log(title);
            console.log(revision);
            console.log(date.toString());
        }).error(function (err) {
            console.log('Error');
            console.log(err); 
        });
});

I get this:

TypeError: Cannot read property 'result' of undefined
    at Bot.<anonymous> (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/mediawiki.js:485:34)
    at Bot._processResponse (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/mediawiki.js:227:29)
    at Request._callback (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/mediawiki.js:179:34)
    at Request.self.callback (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/node_modules/request/request.js:121:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/node_modules/request/request.js:978:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/home/username/src/exercises/mediawiki_api/node_modules/mediawiki/node_modules/request/request.js:929:12)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:920:16

When I console.log the data variable on line 484 of mediawiki.js, I get:

Username: my_username
{ servedby: 'mw1189',
  error: 
   { code: 'mustposttoken',
     info: 'The \'token\' parameter was found in the query string, but must be in the POST body',
     '*': 'See https://en.wikipedia.org/w/api.php for API usage' } }
@brettz9
Copy link

brettz9 commented Apr 23, 2019

I'm looking to possibly address this issue and/or add some enhancements, but was wondering if you were still maintaining the repo, @oliver-moran ?

@brettz9
Copy link

brettz9 commented Apr 23, 2019

Also, @oliver-moran , are you set on using the GPL or would you be open to a more permissive type like MIT?

@brettz9 brettz9 linked a pull request Apr 23, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant