#Tauri JS API telling me I have incorrect function arguments?

6 messages · Page 1 of 1 (latest)

low wigeon
#

Hi, I'm trying to execute a very simple command:

#[tauri::command]
fn get_ip(query: String, handle: AppHandle) -> Option<Connection>

I've registered it in my tauri::Builder...

  .invoke_handler(tauri::generate_handler![get_ip])

And now I'm trying to call it in my javascript:

const cache = await invoke("get_ip", { "query": ip });

I thought that this would work fine (it seems to mirror the examples on the website), but I am getting this strange error in the console:

#
Unhandled Promise Rejection: invalid args `query` for command `get_ip`: command get_ip missing required key query
#

Any idea why this is?

wet raven
#

can you try without the quotes around "query" in your javascript?

low wigeon
#

Ah I guess that must've fixed it

#

Thanks