2019-02-03 17:23:33 +07:00
|
|
|
import API from './api';
|
2019-06-22 16:43:59 +07:00
|
|
|
import { PackageMetaInterface } from 'types/packageMeta';
|
2019-02-03 17:23:33 +07:00
|
|
|
|
2019-08-25 19:34:27 +07:00
|
|
|
export async function callReadme(packageName): Promise<string | {}> {
|
|
|
|
return await API.request<string | {}>(`package/readme/${packageName}`, 'GET');
|
2019-06-20 19:37:28 +07:00
|
|
|
}
|
2019-02-03 17:23:33 +07:00
|
|
|
|
2019-08-25 19:34:27 +07:00
|
|
|
export async function callDetailPage(packageName): Promise<PackageMetaInterface | {}> {
|
2019-07-09 15:48:00 +07:00
|
|
|
const packageMeta = await API.request<PackageMetaInterface | {}>(`sidebar/${packageName}`, 'GET');
|
2019-02-03 17:23:33 +07:00
|
|
|
|
2019-08-25 19:34:27 +07:00
|
|
|
return packageMeta;
|
2019-02-03 17:23:33 +07:00
|
|
|
}
|
2019-08-25 22:39:15 +07:00
|
|
|
|
|
|
|
export 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
|
|
|
|
return API.request(`search/${encodeURIComponent(value)}`, 'GET', { signal, headers: {} });
|
|
|
|
}
|