I have a Node.js project in PhpStorm that runs the index.js
file just fine when I click the Run command, but now I need to run that with query strings in the URL (e.g. index.js?q=query
) and get the query string parameter using something like req.query
in Express. Problem is I am new to PhpStorm and cannot figure out how to run the scrips with parameters in the URL.
So far I only see the option to run the index.js
file but no option to run index.js?q=query
. Normally I would just load the script in a browser but that kind of defeats the purpose of using a headless browser and it would require me to copy the application from the PhpStorm project file to a directory in XAMPP.
If I run a command like node index.js
it works fine but if I change that to node index.js?q=query
I get an error saying "Error: Cannot find module"
I am also not sure if I am using the right syntax for accessing the query parameters via Express.
const express = require('express')
const exp = express();
const url = exp.req.query.url;
const keyword = exp.req.query.q;
const source = exp.req.query.source;