Call method from Pyhton to Js

Hi, i am trying to customize custom script to call method from the python and try to filter using js
i am quiet new with the server side customization here is my script
Customer.py

@frappe.whitelist()
def get_prod_type():
value = “metal”
return value

Customer.js

  frm.fields_dict['item_class'].get_query = function(doc) {
     frappe.call({
        method: "erpnext.selling.doctype.customer.customer.get_prod_type",
     callback: function(r) {
      filters: [
         ['Item Group', 'parent', 'in',r.message],
           ['Item Group', 'is_group', '=',0],
         ]
      }
      })
  }

what i try to simulate in the script is at least to call “Metal” from the python script to filter in the java script. Though it turns out not filtering anything it just show everything can anyone point it out what i do wrong.
Any kind of help will be much appreciated

So if you were to console.log(r.message) you would see that it contains only “metal”. The filters object that you have there is not going to do anything but isn’t syntactically invalid; it’s code that doesn’t execute. If you want to pass an argument to the python function, do that in ‘args’. The keys of args must exactly match the arguments of your python function.

The “how do I filter” question is worth answering on its own:
Frappe has a specific API for passing filters to SQL queries. While this is used all over the place, it follows the same idea: you are calling a method and it’s matching things based on the arguments you provide. The “filters” that you see in JS are setting the filters before that API is called. In short you have the right ideas slightly out of order. Here is the reference

To answer your question “how do I filter a response in Javascript”, in the Frappe context, generally don’t do it. It’s a bit of an anti pattern. All the tools are there to ask a better question from JS rather than filtering a lot of results in the browser.

thank you so much for your response. i’m quiet new to this, i will try to simulate with a correct condition based on your reference. thank you!