How can I create a server and make http get request in electron?


#1

I am trying to create a server and http get request to the server by electron, but i dont know to process as i am new with electron. Can anyone help with this?


#2

it’s easier than i initially thought! :smiley:
in your main file (index | app | main | whathever) .js (see the entry point in package.json file) create the server (i’m using express js instead og node’s built-in)

it will be something like

const electron = require('electron');
var express = require("express");
var server = express();
const app = electron.app; 

server.get("/data/:parameter/:moreparameter", (req, res) => {
  //here the magic happens
  res.send("send something back") OR res.render("pagename",{some json arguments})
})

more or less this is a very “basic” server with electron and expressjs


#3

how can i do ?


#4

mmmm well…

read the part that i wrote, copy an paste in your file, and run it…

sorry for the question, do you know how to make it run?