Skip to content

Commit

Permalink
chore(Innertube#getSearchSuggestions): Use fetch_function instead o…
Browse files Browse the repository at this point in the history
…f `fetch`

It is not an InnerTube request.
  • Loading branch information
LuanRT committed Dec 24, 2024
1 parent 75b8964 commit b7c0421
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Innertube.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,12 @@ export default class Innertube {
if (previous_query)
url.searchParams.set('pq', previous_query);

const response = await this.#session.http.fetch(url);
const response = await this.#session.http.fetch_function(url, {
headers: {
'Cookie': this.#session.cookie || ''
}
});

const text = await response.text();

const data = JSON.parse(text.replace('window.google.ac.h(', '').slice(0, -1));
Expand Down
2 changes: 2 additions & 0 deletions src/core/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export default class Session extends EventEmitter {
public api_version: string;
public account_index: number;
public po_token?: string;
public cookie?: string;

constructor(context: Context, api_key: string, api_version: string, account_index: number, player?: Player, cookie?: string, fetch?: FetchFunction, cache?: ICache, po_token?: string) {
super();
Expand All @@ -239,6 +240,7 @@ export default class Session extends EventEmitter {
this.context = context;
this.player = player;
this.po_token = po_token;
this.cookie = cookie;
}

on(type: 'auth', listener: OAuth2AuthEventHandler): void;
Expand Down

0 comments on commit b7c0421

Please sign in to comment.