JavaScript Node.js Basics Create a Command Line Weather Application Parsing Data and Printing - Solution

Peter Gess
Peter Gess
16,552 Points

Getting error in Node.js: Missing } in template expression somewhere

I am getting the following error:

ERROR:

/home/treehouse/workspace/weather.js:16 const request = https.get(https://api.wunderground.com/api/${8d34e9ce cfb86188}/geolookup/conditions/q/${query}.json, response => { ^ SyntaxError: Missing } in template expression at Object.exports.runInThisContext (vm.js:76:16) at Module.compile (module.js:542:28) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module.load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19)

Here is a snapshot of my current workspace:

https://w.trhou.se/fuec2yclx3

1 Answer

Seth Kroger
MOD
Seth Kroger
Treehouse Moderator 56,182 Points

I think the problem is where you have your API key ...api/${8d34e9cecfb86188}... The key isn't a valid variable name (it starts with a number) and looks like it's the actual key instead of a variable holding it. You should either the interpolation and just have ...api/8d34e9cecfb86188... or create an apiKey constant with that value and use ...api/${apiKey}...

Peter Gess
Peter Gess
16,552 Points

Hi Seth, thanks for helping with that first point. Could you assist me with my other issue? The weather underground API seems to have changed since Andrew's video.

The error I am having is using Andrew's API call with ${query} throws an error of 'temp_f' being undefined and cannot read property. However, on the API docs is shows the call including cities, not the ${query}. Please advise.