10-10-2017 21:32 - edited 10-10-2017 21:32
10-10-2017 21:32 - edited 10-10-2017 21:32
I have been trying to implement the weather sample that is on the messaging API.
First it would not build and through trial and error I discovered there is an extra ; in the sample code.
Changed that, I keep on getting the same error no matter what I do:
Uncaught (in promise) ReferenceError: temperature is not defined
Please help. I would like to use that as a starting point to get tide information.
API key is correct and I tested with a console log showing me the correct url.
Ps on the console log, time stamp for my phone is about 45 minutes behind of device. Is it normal?
Answered! Go to the Best Answer.
10-10-2017 21:49
10-10-2017 21:49
Sorry about the typo on the messaging guide, I've submitted a fix for that.
It looks like there is a second typo there, try this:
var weather = {
temperature: data["main"]["temp"]
}
10-10-2017 21:49
10-10-2017 21:49
Sorry about the typo on the messaging guide, I've submitted a fix for that.
It looks like there is a second typo there, try this:
var weather = {
temperature: data["main"]["temp"]
}
10-10-2017 22:27
10-10-2017 22:27
Ah the = should have been : as well.
I used:
var weather = data["main"]["temp"];
Got the same result 🙂
10-11-2017 00:44
10-11-2017 00:44
temperature is not defined
Are you using that variable somewhere though?
Can you put your project code on Github?
10-11-2017 05:29
10-11-2017 05:29
Thanks JonFitbit.
It works using the fix. It is the same code as from your Messaging Guide. Just copied and pasted, and put some extra console.log to give me messages when something was happening.
WailoK, if I use your code, I get no error message, but it does not read the temperature.
10-12-2017 04:38 - edited 10-12-2017 05:04
10-12-2017 04:38 - edited 10-12-2017 05:04
Strange. It works for me, but I'll change to @JonFitbit's way.
Ah, yes. I also changed the watchapp code to match. Best to do it the official way 🙂