fireship-io / react-course

React - The Full Course
74 stars 41 forks source link

Row 21 in index.js in animalfarm/server should not have ? after q? #4

Open ComputerFrek opened 1 year ago

ComputerFrek commented 1 year ago

Row 21 in index.js in animalfarm/server should not have ? after q?

Should be const q = req.query.q.toLowerCase() || '';

instead of const q = req.query.q?.toLowerCase() || '';

Error received below when running node . `file:///mnt/c/Users//Documents/SourceCodes/animalfarm/server/index.js:21 const q = req.query.q?.toLowerCase() || ''; ^

SyntaxError: Unexpected token '.' at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18) at async link (internal/modules/esm/module_job.js:42:21)`

Code works after removing ?

Umang375 commented 1 year ago

It should work, there is nothing wrong in the const q = req.query.q?.toLowerCase() || ''; it would help if you share the entire code. Maybe check the node version.