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

396
Views
Error Unable to find JSON file in folder, Javascript

Trying to fetch my json file, but apparently the URL is invalid or wrong as per the warning. Tried to console log modelURL and it looks correct. Console.log Output : ./tm-my-image-model/model.json

Full error

Uncaught Error: Request to ./tm-my-image-model/model.json failed 

with status code 404 const URL = ./tm-my-image-model/;

let model, webcam, maxPredictions, happy, sad, angry;
let refresh = true;


    async function init() {
        if (refresh) {
            refresh = false;
            const metadataURL = URL + "metadata.json";
            const modelURL = URL + "model.json";
            
      console.log(modelURL)
}}

File Structure

enter image description here

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

0

How are you doing the fetch? (It is not in the code you provided).

In Node.js to work with the file system you need to use the native module fs.

Node.js v18.2.0 documentation File system

about 4 years ago · Juan Pablo Isaza Report

0

This depends where you're calling it from. Currently, the path is relative, and where it's relative to can get quite confusing quite quickly. Note that if you're able to send the path with the page render, that might be good too, since you can then resolve the path from node, and avoid any ajax.

That being said, if possible (since this looks to be node anyway), it would probably be a whole lot easier to use require("x") (or import x from "x" if ESM), or, if you need it to load asynchronously, using the await import("x") syntax.

If you're using server side rendering only, it may be useful to make a network call and fetch the file from your server asynchronously as well.

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!