Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
Load a file from localSystem with javascript without a server

I make an app with javascript, I need to work with no any server in the local network. Only chrome browser run from /Services/ServiceFinder/index.html.

When load index.html need to read a XLSX file from the same directory as a file(i use the SheetJS library to read XLSX as a db and convert it to a javascript object).

I use fetch after window load event but i take an error message "The file is not loaded successfully."

window.addEventListener('load', (event) => {

//Get the file input
var file = "./ServicesData.XLSX";

//Load file
fetch(file, {mode: "no-cors"}).then(response => {

    if(response.ok) {
        console.log("%cThe file is loaded successfully.", styleConsoleLog);
    }else{
        console.error("The file is not loaded successfully.");
    };
    return response.arrayBuffer();

}).then(arrayBuffer => {

The same code is working perfectly when i use the server.

run only from chrome

run with a server

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can simply create a http server on the local network and serve the file there with NodeJS.

/* ====== create node.js server with core 'http' module ====== */
// dependencies
const http = require("http");

// PORT
const PORT = 3000;

// server create
const server = http.createServer((req, res) => {
   if (req.url === "/") {
      res.write("This is home page.");
      res.end();
   } else if (req.url === "/about" && req.method === "GET") {
      res.write("This is about page.");
      res.end();
   } else {
      res.write("Not Found!");
      res.end();
   }
});

// server listen port
server.listen(PORT);

console.log(`Server is running on PORT: ${PORT}`);

// ======== Instructions ========
// save this as index.js
// you have to download and install node.js on your machine
// open terminal or command prompt
// type node index.js
// find your server at http://your.network.ip.address:port/

learn about it here: How could others, on a local network, access my NodeJS app while it's running on my machine?

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!