Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issues with Messaging and sample

ANSWERED

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?

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

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"]
}

 

 

View best answer in original post

Best Answer
0 Votes
5 REPLIES 5

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"]
}

 

 

Best Answer
0 Votes

Ah the = should have been : as well.

I used:

 

var weather = data["main"]["temp"];

 Got the same result 🙂

Best Answer
0 Votes
temperature is not defined

Are you using that variable somewhere though?

Can you put your project code on Github?

 

 

 

Best Answer
0 Votes

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.

Best Answer
0 Votes

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 🙂

Best Answer
0 Votes