0

When trying to load a json file and load it into an object called players I get an error and the server stops, does anyone know why? The code;

function getjson(){
        fs.readFile('./src/player.json', 'utf8', (err, jsonString) => {
            if (err) {
                console.log("File read failed:", err)
                return
            }else{
                players = JSON.parse(jsonString);
            }
        })
    }

The error;

Uncaught SyntaxError: Unexpected end of JSON input
3
  • Does this link answer your question? Commented Jan 28, 2021 at 19:41
  • 1
    Lets see the content of jsonString Commented Jan 28, 2021 at 20:15
  • definitely something wrong inside jsonString Commented Jan 29, 2021 at 1:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.