Skip to content

Commit 3043fa5

Browse files
Rushikesh-Argade-StackAmitkanswal
authored andcommitted
feat: add config support to search method for branch-specific searches
- Add optional config parameter to search method with safe default - Support branch-specific searches via config.branch - Update JSDoc documentation for new parameter - Maintain backward compatibility with existing API - Follow consistent pattern with other stack methods
1 parent 3097bd9 commit 3043fa5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/stack/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,15 @@ class Stack {
113113
* Gets the results of the search based on user query
114114
* @param queries Array of key value pair of query parameters
115115
* @param apiKey API key of the stack
116+
* @param config Optional configuration. Only pass this if you need to query a specific branch using `{ branch: 'branch-name' }. If not provided, queries the default branch.`
116117
* @returns Result of the query
117118
*/
118-
search(queries: StackSearchQuery, apiKey: string | null = this._data.api_key) {
119-
const options = { params: queries, api_key: apiKey, action: "search" };
119+
search(queries: StackSearchQuery, apiKey: string | null = this._data.api_key, config: { [key: string]: any } = {}) {
120+
const { branch } = config;
121+
const options: any = { params: queries, api_key: apiKey, action: "search" };
122+
if (branch) {
123+
options.headers = { branch };
124+
}
120125
return this._connection
121126
.sendToParent("stackQuery", options)
122127
.then(onData)

0 commit comments

Comments
 (0)