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 Building a Command Line Application Making a GET Request with https

Gabriel Edward Gabato
Gabriel Edward Gabato
4,736 Points

Why do I get a 404 if I type with ('') but not (``)?

I thought that they are equal. For example:

'https://teamtreehouse.com/${username}.json' gets me a 404

but

https://teamtreehouse.com/${username}.json gives me a 200

Thanks in advance!

2 Answers

Andrew Thompson
Andrew Thompson
28,063 Points

Hi Edward,

The reason this is happening is that backticks are the new syntax for creating Template Strings in ES2015. Single quote marks and double quote marks are indeed equal but using backticks will allow you to use string substitution. Substitution allows us to take any valid JavaScript expression and inside a Template Literal, the result will be output as part of the same string. I have included two examples below of the same code, one written in ES5 and the other in ES2016 to demonstrate this

ES5

var username = 'user';

var req = https.get('https://teamtreehouse.com/' + username + '.json';

ES2015

const username = 'user';

const req = https.get(`https://teamtreehouse.com/${username}.json`;

how can I make this sign with keyboard? I do not find anything on web.

Andrew Thompson
Andrew Thompson
28,063 Points

Hi Irene,

Not sure if you have worked this out yet... If you're on a Mac, it will be between the shift key and the Z key (UK keyboard). If you are on a US keyboard, I think it is below the ESC key.

It shares a key with the tilde character.

Hope this helps.