Witam. Chciałbym stworzyć swój moduł w node.jsie, do mojego API. O to mój skrypt:
index.js
module.exports = {
cos: () => {
require("./apis/cos.js");
},
};
cos.js
const fetch = require(“node-fetch”);
fetch(“http://localhost/api/index.php?json=true&type=cenzura”).then((res) => res.json()).then((body) => {
exports.cos = body.message;
});
app.js
const xd = require(“gowno”);
console.log(xd.cos());