I have this:
<script>
function gettingJSON(){
$.getJSON("http://api.openweathermap.org/data/2.5/weather?q=London&appid=",function(json){
console.log(JSON.stringify(json));
});
}
</script>
when i run this, and look at my console, i get this erorr:
[Error] Failed to load resource: the server responded with a status of 401 (Unauthorized) (weather, line 0)
my api key matches the one in the openweathermap dashboard, so wondering y its not acc working. Maybe i'm missing something. any ideaS?
I think you just need to put your api key in the query string.
http://api.openweathermap.org/data/2.5/weather?q=London&appid=[HERE]
Moreover it requires a couple of hours to be activated and ready to use.
Related
I am using Sails and Mysql to handle the database of my app. I recently clicked on a chrome autofill URL that took me to a 404'd page, since that url localhost:1337/companies was not active in this project.
Ever since I did that, my app returns
error: Sending 500 ("Server Error") response:
Error (E_UNKNOWN) :: Encountered an unexpected error
: ER_BAD_FIELD_ERROR: Unknown column 'NaN' in 'where clause'
and
Details: Error: ER_BAD_FIELD_ERROR: Unknown column 'NaN' in 'where clause'
any time I go to a url in my app. I tried cloning my app and relinking the database to no avail. I see this is a common issue people run into with sails, but none of the mentioned solutions were able to fix it for me.
Everything was working before I clicked that URL which makes me believe it may be a route issue, but the app still works, it will just fill up my terminal with the above errors.
Any help is greatly appreciated!
Edit: this is the custom API call I was working on in my controller.js when I started seeing the error:
winner: function (req, res) {
User.findOne({id: req.param('id')}).exec(function(err, user) {
if (err) {
return res.negotiate(err);
}
else {
var u = user;
u.totalwins++;
u.save();
sails.io.sockets.emit("chat", {verb:"score", data:{id: req.param('id'), name: user.name}});
}
});
}
Also receiving this error in my chrome-browser console:
:1337/user/quizzes Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I'm having a small issue with getting data from a API. I get the error "GET https://ipinfo.io/ 401 (Unauthorized)". Relevant code:
$.getJSON('//ipinfo.io', function(response){
console.log(response.loc)
var latlngIP = location['loc'].split(',');
var latIP = latlngIP[0];
var lngIP = lnglngIP[1];
API: https://ipinfo.io/
I did not exceed the 1000 uses per day limit.
EDIT:before you suggest it, adding https or http did not fix it.
You'll get a 401 for https if you do not have an access token. See https://ipinfo.io/pricing
EDIT: HTTPS access is now free: https://twitter.com/ipinfoio/status/779374440417103872
There are lots of question like my question but I didn't any working solution.
I am using AngularJS and WebApi2 in my application.
Here is the JS code which call the initial API.
(function (module) {
var baseUrl= "http://localhost:85";
module.constant('Config', baseUrl);
module.service('identities', ['$http', function ($http) {
var uri = baseUrl+ '/api/controller/GetRole';
var identities = {};
identities.get = function () {
var temp = $http.get(uri);
console.log(temp, "identities");
return temp;
}
return identities;
}]);
This function call the GetRole method in web API controller to retrieve user role.The output of this method is JSON with user details.
I have deployed the application on a server to port 85. When I run the application it's throwing error in Chrome:
net::ERR_CONNECTION_REFUSED
and in IE 11:
XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd
There is no log created in IIS for this request.
Using fiddler I got this in Raw with status code 502 in response.
The connection to 'localhost' failed.
Error: ConnectionRefused (0x274d).
System.Net.Sockets.SocketException No connection could be made because the target machine actively refused it 127.0.0.1:85.
I have also tried by disabling the CORS in chrome but no luck.
IF I use IP address of server instead of localhost as baseUrl in angular JS code then it's working fine.
Why it's not working with localhost?
I am doing a GET call and Error for me is 00002efd not 00002ef3.
I'm working on a Python API to handle REST calls to MongoDB. The API is based on Kule (and thus includes Bottle and PyMongo modules). The front-end is built using node.js. I have been developing and testing on localhost with the API, front-end, and MongoDB on different ports.
I have set up the API and have been trying to get CRUD requests to work. I can get these to work from a Python script as well as from Javascript running on Apache server. However, when I add the same code to the front-end, GET works, but POST fails with a 500 error.
This POST code works on the Apache server:
var myrequest=new XMLHttpRequest();
myrequest.onreadystatechange=function(){
if (myrequest.readyState==4){
if (myrequest.status==201){
alert(myrequest.responseText);
} else{
alert("An error has occured making the request");
}
}
}
myrequest.open("POST", "http://localhost:8080/items", true);
myrequest.setRequestHeader("Content-type", "application/json;charset=UTF-8");
myrequest.send(JSON.stringify({'name' : 'Name', 'description' : 'Description'}));
When I add this to the front-end, I get the following traceback from Kule:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\bottle.py", line 764, in _handle
return route.call(**args)
File "C:\Python27\lib\site-packages\bottle.py", line 1625, in wrapper
rv = callback(*a, **ka)
File "C:\Python27\lib\site-packages\bottle.py", line 1575, in wrapper
rv = callback(*a, **ka)
File "C:\Python27\lib\site-packages\kule\kule.py", line 64, in post_list
inserted = collection.insert(request.json)
File "C:\Python27\lib\site-packages\pymongo\collection.py", line 351, in insert
docs = [self.__database._fix_incoming(doc, self) for doc in docs]
TypeError: 'NoneType' object is not iterable
127.0.0.1 - - [24/Jun/2014 07:53:40] "POST /scenarios HTTP/1.1" 500 50
So, what am I doing wrong? Why does the Javascript break in node.js? I have GET working, but POST fails. Why?
Thanks!
I found my error.
myrequest.setRequestHeader("Content-type", "application/json;charset=UTF-8");
"Content-type" should be "Content-Type" with an upercase "T".
Silly mistake. Left as a note to others.
Server :
Meteor.publish('trades', function() {
return Trades.find();
});
Client:
Meteor.subscribe("trades");
Both:
Trades = new Meteor.Collection('trades');
When I run meteor, its giving me
TypeError: Object # has no method 'subscribe'
Any suggestions?
You might have your client code running in the root directory /. It would also then execute on the server and give this error. (Not sure if its this).