Skip to content
This repository was archived by the owner on Jan 16, 2022. It is now read-only.

Commit 644f9a3

Browse files
committed
fix: missing headers on search endpoint with token
Headers should be part of the options if we override options. https://github.com/verdaccio/ui/issues/118
1 parent 97e8448 commit 644f9a3

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/components/Search/Search.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import debounce from 'lodash/debounce';
99
import API from '../../utils/api';
1010
import AutoComplete from '../AutoComplete';
1111
import colors from '../../utils/styles/colors';
12+
import { callSearch } from '../../utils/calls';
1213

1314
export interface State {
1415
search: string;
@@ -148,7 +149,7 @@ export class Search extends Component<RouteComponentProps<{}>, State> {
148149
const signal = controller.signal;
149150
// Keep track of search requests.
150151
this.requestList.push(controller);
151-
const suggestions = await API.request(`search/${encodeURIComponent(value)}`, 'GET', { signal });
152+
const suggestions = callSearch(value, signal);
152153
// @ts-ignore
153154
this.setState({
154155
suggestions,

src/utils/calls.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,11 @@ export async function callDetailPage(packageName): Promise<PackageMetaInterface
1010

1111
return packageMeta;
1212
}
13+
14+
export async function callSearch(value: string, signal: any) {
15+
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#Browser_compatibility
16+
// FUTURE: signal is not well supported for IE and Samsung Browser
17+
const suggestions = await API.request(`search/${encodeURIComponent(value)}`, 'GET', { signal, headers: {} });
18+
19+
return suggestions;
20+
}

0 commit comments

Comments
 (0)