Patrik Horváth Patrik Horváth - 22 days ago 6
Node.js Question

JavaScript Node.JS - ${variable} no works

i started lerning Node.JS few days ago and i found little bit problem my JavaScript syntax no works at all in Node.JS i hope someone can tell me why, here are Code Examples,

Working Code :

const request = https.get("api.api/zip=94040&apiid=randomkey125dessd", () => { ... })


Doesnt Work (error 404), zip is constant and api is JSON with property key:

const request = https.get("api.api/zip=${zip}&apiid=${api.key}", () => { ... })

Answer Source

You are using Template litterals wrong.


This is

https.get(`api.api/zip=${zip}&apiid=${api.key}`,

and not

https.get("api.api/zip=${zip}&apiid=${api.key}",