fool
March 3, 2020, 10:42pm
21
Hmm, I am not sure if that is the best way to include a file but I am not a major functions user. We have a known working example of including a separate file shown here:
const axios = require("axios")
const path = require("path")
const fs = require("fs")
const outside = require("../outside.js")
// path of the included file will be `process.env.LAMBDA_TASK_ROOT/{name_of_function}/{included_filename}`
const fileName = "./zipped-function/some-other.js"
const resolved = (process.env.LAMBDA_TASK_ROOT)? path.resolve(process.env.LAMBDA_TASK_ROOT, fileName):path.resolve(__dirname, fileName)
fs.readFile(resolved, "utf8", (err, results) => console.log(results))
console.log(outside.message)
exports.handler = function(event, context, callback) {
// Perform the API call.
const get = () => {
axios
.get("https://icanhazdadjoke.com/", { headers: { Accept: "application/json" } })
.then((response) => {
console.log(response.data)
This file has been truncated. show original
… can you try to emulate that pattern a bit to see if it works better?
1 Like