Frappe is undefined in js file

Good morning all, I got error with frappe when using it in custom frontend js file. System notice: frappe is undefined. This is the code:

export function sendMessageToIframe(iframeId, message) {
    frappe.ready(function() {
                  console.log(frappe.session.user);
		user = frappe.session.user;
		callFunction(iframeId, message, user)
              });
}
Folder tree:
frappe_project
└── apps
    ├── frappe
    └── custom_app
        ├── frontend
        │   └── public
        │       └── utils
        │           └── file.js ***
        ├── custom_app
        └── node_modules

Small Reference: How to handle the JS in custom app?

1 Like

Thank u for support. But it’s not working. Frappe is still not defined although i used hook, public/js as link

I will try to get information from Frappe through creating Custom API to use in JavaScripts File. Hopefully someone can provide better solution. Thank u so much