Is it possible to use .ui.search with POST method instead of GET ? Any examples is appreciated. Thank You!
<div class="ui search">
<div class="ui left icon input">
<input class="prompt" type="text" placeholder="Search GitHub">
<i class="github icon"></i>
</div>
</div>
$('.ui.search')
.search({
apiSettings: {
url: '//api.github.com/search/repositories?q={query}'
},
fields: {
results : 'items',
title : 'name',
url : 'html_url'
},
minCharacters : 3
})
;
Have you tried using the "method" option? Like this:
$('.ui.search')
.search({
apiSettings: {
url: '//api.github.com/search/repositories?q={query}',
method: 'GET'
},
fields: {
results : 'items',
title : 'name',
url : 'html_url'
},
minCharacters : 3
})
;
Method should have you covered. You can configure any normal API settings, see the api docs for more details.
@IonutBajescu I think I was asking about ''POST'' not GET which is default.
@jlukic There is no POST example that I could find. Can you give an example please ?
We mean, how to put {query} on the post parameter?
we have tried this:
$('#search-user')
.search({
apiSettings: {
url: window.location.href,
method: 'POST',
data: {
term: '{query}' // <--- this, but it doesnt replaced like on the `url` param
}
},
fields: {
results : 'items',
title : 'name',
url : 'html_url'
},
minCharacters : 3
})
;
Hi @rizalgowandy, the search component automatically takes an input value and replaces {query} in a url with it. Here’s an example, see the “Network” tab in your browser’s developer tools to see the request: https://jsfiddle.net/19fb6uLv/
I'm using a "beforeSend" callback function in the apiSettings to modify the data like this:
https://jsfiddle.net/pkdukdjv
Most helpful comment
@IonutBajescu I think I was asking about ''POST'' not GET which is default.
@jlukic There is no POST example that I could find. Can you give an example please ?