(search)
- search - Search for a term
Search for a term
import { SDK } from "@lukehagar/discoursejs";
const sdk = new SDK();
async function run() {
const result = await sdk.search.search(1, "api @blake #support tags:api after:2021-06-04 in:unseen in:open order:latest_topic");
// Handle the result
console.log(result)
}
run();
The standalone function version of this method:
import { SDKCore } from "@lukehagar/discoursejs/core.js";
import { searchSearch } from "@lukehagar/discoursejs/funcs/searchSearch.js";
// Use `SDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const sdk = new SDKCore();
async function run() {
const res = await searchSearch(sdk, 1, "api @blake #support tags:api after:2021-06-04 in:unseen in:open order:latest_topic");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result)
}
run();
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
page |
number | ➖ | N/A | [object Object] |
q |
string | ➖ | The query string needs to be url encoded and is made up of the following options: - Search term. This is just a string. Usually it would be the first item in the query. - @<username> : Use the @ followed by the username to specify posts by this user.- #<category> : Use the # followed by the category slug to search within this category.- tags: : api,solved or for posts that have all the specified tags api+solved .- before: : yyyy-mm-dd - after: : yyyy-mm-dd - order: : latest , likes , views , latest_topic - assigned: : username (without @ )- in: : title , likes , personal , messages , seen , unseen , posted , created , watching , tracking , bookmarks , assigned , unassigned , first , pinned , wiki - with: : images - status: : open , closed , public , archived , noreplies , single_user , solved , unsolved - group: : group_name or group_id- group_messages: : group_name or group_id- min_posts: : 1- max_posts: : 10- min_views: : 1- max_views: : 10If you are using cURL you can use the -G and the --data-urlencode flags to encode the query:<br/>curl -i -sS -X GET -G "http://localhost:4200/search.json" \<br/>--data-urlencode 'q=wordpress @scossar #fun after:2020-01-01'<br/> |
[object Object] |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. | |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
|
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.SearchResponseBody>
Error Object | Status Code | Content Type |
---|---|---|
errors.SDKError | 4xx-5xx | / |