Using xhrSelectSearch with the "http_verb: GET" option results in unusual URL parameters sent to the endpoint.
To repro this, create a new plugin and add the following to the Form Fields:
Save the plugin and then type the following four characters one at a time into the created Project text field:
g
o
a
l
Typing each character will invoke a call to the GET endpoint.
After typing the last character, inspect the URL passed to the last GET endpoint call in the debugger, you will see the following:
https://trmnl.com/custom_plugin_example_xhr_select_search.json?function=project&query=&plugin_setting=[object+Object]?function=project&query=g&plugin_setting=[object+Object]?function=project&query=go&plugin_setting=[object+Object]?function=project&query=goa&plugin_setting=[object+Object]?function=project&query=goal&plugin_setting=[object+Object]
There are several unusual things about this URL.
First, it appears to be trying to pass plugin settings in the URL but the setting object did not get stringified and thus you see that "[object+Object]" stuff.
Second, the URL seems to contain multiple query parameters, each one summarizing the contents of the text box when each new character was typed. For example:
query=""
query="g"
query="go"
query="goa"
query="goal"
Some ideas for how to improve this behavior:
It might make sense to just skip passing the plugin settings in the URL as some kind of encapsulated JSON or set of parameters. Most people implementing a GET function will just want the query string. If they want all the plugin settings, they can implement a POST instead and all the settings will come along naturally as a robust JSON object.
It would also make sense to just send the LAST entered query string in the URL (i.e. query="goal" in my example), instead of including all previous queries. Implementors of GET functions are just going to want to use the latest query string, so all those previous ones will likely not be used for anything.
So, in my example, the final URL in my example could be simplified to:
https://trmnl.com/custom_plugin_example_xhr_select_search.json?function=project&query=goal
Using xhrSelectSearch with the "http_verb: GET" option results in unusual URL parameters sent to the endpoint.
To repro this, create a new plugin and add the following to the Form Fields:
name: Project
field_type: xhrSelectSearch
http_verb: GET
optional: true
endpoint: https://trmnl.com/custom_plugin_example_xhr_select_search.json
Save the plugin and then type the following four characters one at a time into the created Project text field:
g
o
a
l
Typing each character will invoke a call to the GET endpoint.
After typing the last character, inspect the URL passed to the last GET endpoint call in the debugger, you will see the following:
https://trmnl.com/custom_plugin_example_xhr_select_search.json?function=project&query=&plugin_setting=[object+Object]?function=project&query=g&plugin_setting=[object+Object]?function=project&query=go&plugin_setting=[object+Object]?function=project&query=goa&plugin_setting=[object+Object]?function=project&query=goal&plugin_setting=[object+Object]
There are several unusual things about this URL.
First, it appears to be trying to pass plugin settings in the URL but the setting object did not get stringified and thus you see that "[object+Object]" stuff.
Second, the URL seems to contain multiple query parameters, each one summarizing the contents of the text box when each new character was typed. For example:
query=""
query="g"
query="go"
query="goa"
query="goal"
Some ideas for how to improve this behavior:
It might make sense to just skip passing the plugin settings in the URL as some kind of encapsulated JSON or set of parameters. Most people implementing a GET function will just want the query string. If they want all the plugin settings, they can implement a POST instead and all the settings will come along naturally as a robust JSON object.
It would also make sense to just send the LAST entered query string in the URL (i.e. query="goal" in my example), instead of including all previous queries. Implementors of GET functions are just going to want to use the latest query string, so all those previous ones will likely not be used for anything.
So, in my example, the final URL in my example could be simplified to:
https://trmnl.com/custom_plugin_example_xhr_select_search.json?function=project&query=goal