Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Peter Gess
Peter Gess
16,553 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
Seth Kroger
56,413 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,553 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.