I have converted the JavaScript code to Typescript and getting the error
Module has no default export
I have tried importing using the curly braces and exporting using module.exports but none of them worked.
contactController.ts
const contacts: String[] = [];
// Handle index actions
exports.index = (req: any, res: any) => {
res.json({
data: contacts,
message: "Contacts retrieved successfully",
status: "success"
});
};
// Handle create contact actions
exports.new = (req: any, res: any) => {
// save the contact and check for errors
contacts.push("Pyramids");
res.json({
data: contact,
message: "New contact created!"
});
};
api-route.ts
import contactController from "./contactController";
In the api-routes.ts, when I am trying to import the contactController module it is throwing the error
Module has no default export
How can I import without the error? I have tried using "import {contactController} from "./contactController" but that did not work as well.