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

Commit

Permalink
fix: missing headers on search endpoint with token
Browse files Browse the repository at this point in the history
Headers should be part of the options if we override options.

https://github.com/verdaccio/ui/issues/118
  • Loading branch information
juanpicado committed Aug 25, 2019
1 parent 97e8448 commit 644f9a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/Search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import debounce from 'lodash/debounce';
import API from '../../utils/api';
import AutoComplete from '../AutoComplete';
import colors from '../../utils/styles/colors';
import { callSearch } from '../../utils/calls';

export interface State {
search: string;
Expand Down Expand Up @@ -148,7 +149,7 @@ export class Search extends Component<RouteComponentProps<{}>, State> {
const signal = controller.signal;
// Keep track of search requests.
this.requestList.push(controller);
const suggestions = await API.request(`search/${encodeURIComponent(value)}`, 'GET', { signal });
const suggestions = callSearch(value, signal);
// @ts-ignore
this.setState({
suggestions,
Expand Down
8 changes: 8 additions & 0 deletions src/utils/calls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ export async function callDetailPage(packageName): Promise<PackageMetaInterface

return packageMeta;
}

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

return suggestions;
}

0 comments on commit 644f9a3

Please sign in to comment.