0

I'm trying to make an Electron app. In files, in example I have app.html, and I need to send GET variable like ?id=54&q=asd to the receiver.html, and then I'll get this id and q variables on the receiver.html.

Everybody knows, in PHP we do it like that:

app.html:

<a href="receiver.php?id=54&q=asd">Click Me</a>

receiver.php:

<?php
echo $_GET['id']." ".$_GET['q'];
?>

In electron we redirects pages as this Stackoverflow issue suggested.

But how can I get the GET variables in Electron.js?

sundowatch
  • 3,012
  • 3
  • 38
  • 66
  • Does this answer your question? [How to pass parameters from main process to render processes in Electron](https://stackoverflow.com/questions/38335004/how-to-pass-parameters-from-main-process-to-render-processes-in-electron) – Yonlif Jun 01 '20 at 17:16

1 Answers1

0

You can use the URLSearchParams class to parse the URL and get any query variables with the .get function, like this:

const queryVariables = new URLSearchParams(window.location.search)
console.log(queryVariables.get('id') + " " + queryVariables.get('q'));

I hope this helps.