I have Problem with finding a json file

Hi @9orsaan :wave:

How are you reading the JSON file in your function? If you are using readFileSync or other fs method you will need to use the included_files configuration option in the project’s netlify.toml. E.g.

[functions]
  included_files = ["all/channels.json"]

Check out this thread for more information on usage We don't understand how the included_files [functions] parameter works

If you are using require or import, then this file is bundled with the function at build time, and there is no need for the above configuration. E.g.

const testJSON = require('../data/test.json')

exports.handler = async(event) => {

  return {
    statusCode: 200,
    body: JSON.stringify(testJSON),
    headers: {
      'Content-Type': 'application/json',
    }
  }

}
1 Like