Hey dear community,
I am pretty new in developing frappe apps and in developing in general.
I tried to set up an public API that I call from JavaScript using frappe.call().
But somehow, the desired function in api.py is not being executed.
Here is my code:
JavaScript:
function do_somehting(){
frappe.call({
method: "custom_app.api.some_function",
callback: (response) => {
console.log(response.message);
}
});
}
document.querySelector("#some_button").addEventListener("click",do_somehting);
Code in custom_app/api.py
import frappe
@frappe.whitelist()
def some_function():
doc = frappe.get_doc({
"doctype": "Project",
"title": "My new project",
"status": "Open"
})
doc.insert()
I clicked the button that was linked to the JS-function, but now there is no new project in my database. Am I missing something fundamental here?
Any help is very much appreciated.
Thank you and have a nice day,
Armin