using JSON data in client side javascript file

Viewed 1038

Im fairly new to node.js and express. My question is how to correctly retrieve json data in a client side javascript file since im getting a 404 code about the .json file not being found.

my file structure is a generic express structure and the .json file is in the nodeapp folder right below the package.json file and app.js. Im trying to access this file from a javascript file that is saved in public/javascripts folder but can seem to get around it. here is the function im trying to implement in the .js file:

function getJSONData(){
    var json;
    $.getJSON('/public/web_text.json', function(data){

        json = data
    });
} 
1 Answers
Related