Hello,
I get a problem since I add mongo db to my netlify function.
[ERROR] No loader is configured for ".node" files: ../../../node_modules/@napi-rs/snappy-darwin-arm64/snappy.darwin-arm64.node
../../../node_modules/snappy/index.js:1:2291:
1 │ ...ding=require("./snappy.darwin-arm64.node"):nativeBinding=require("@napi-rs/snappy-darwin-arm64")}catch(e){loadError=e}break;default:throw new Error(`Unsupporte...
╵
My function :
import { Handler } from "@netlify/functions";
const { MongoClient} = require("mongodb");
//require('dotenv').config();
const handler: Handler = async (event, context) => {
// your server-side functionality
console.log("let's check order at faire");
const mongoClient = new MongoClient("mongodb+srv://ms_dev:pwd_ms_dev@cluster0.gcezcdz.mongodb.net/?retryWrites=true&w=majority");
const clientPromise = mongoClient.connect();
try {
const database = (await clientPromise).db("fairedata");
const collection = database.collection("order");
const result = await collection.find({}).limit(10).toArray();
return {
statusCode: 200,
body: JSON.stringify(result),
};
} catch (error) {
return {
statusCode: 500,
body: JSON.stringify({ message: "Internal Server Error " }),
}
}
};
export { handler };
My package.json
"dependencies": {
"@netlify/functions": "^1.3.0",
"mongodb": "4.11"
}
My netlify.toml
[functions."check-order"]
schedule = "@hourly"
I don’t find anything on internet. And I get this since I added mongo
Regard,