Whenever I call the below method (CoffeeScript) that is on the server I get "Scripts should use an informative User-Agent string with contact information, or they may be IP-blocked without notice" from Wikipedia. How do I include user-agent info in the call? Or does it grab this from Meteor Accounts (which I'm not using yet)? thank you for any help...
Meteor.methods
wpSearch: (queryStr) ->
result = Meteor.http.call "GET", "http://en.wikipedia.org/w/api.php",
params:
action: "query"
list: "search"
format: "json"
srwhat: "text"
srsearch: queryStr
To clarify the previous answer for future visitors, the syntax for Meteor.http.get is as follows:
result = Meteor.http.get("https://api.github.com/user", {
headers: {
"User-Agent": "Meteor/1.0"
},
params: {
access_token: accessToken
}
});
Note the curly braces around the headers option and the comma afterwards separating the headers and params options (it's a syntax error without these things). This is example is part of the EventedMind how-to to customize the loginButtons during the onCreateUser() callback.
Just set User-Agent in the headers
parameter (see http://docs.meteor.com/#meteor_http)
Meteor.methods
wpSearch: (queryStr) ->
result = Meteor.http.call "GET", "http://en.wikipedia.org/w/api.php",
headers:
"User-Agent": "Meteor/1.0"
params:
action: "query"
list: "search"
format: "json"
srwhat: "text"
srsearch: queryStr
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With