实现基本功能
This commit is contained in:
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 仓库搜索结果单条记录
|
||||
*/
|
||||
export interface RepositorySearchResultItem {
|
||||
id: number,
|
||||
node_id: string,
|
||||
name: string,
|
||||
full_name: string,
|
||||
private: boolean,
|
||||
stargazers_count: number,
|
||||
watchers_count: number,
|
||||
forks_count:number
|
||||
}
|
||||
|
||||
/**
|
||||
* 仓库搜索结果
|
||||
*/
|
||||
export interface RepositorySearchResultList {
|
||||
total_count:number,
|
||||
incomplete_results:boolean,
|
||||
items:RepositorySearchResultItem[]
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { RepositorySearchResultList } from './api'
|
||||
|
||||
export async function search (keyword:string, page:number) {
|
||||
const url = new URL('https://api.github.com/search/repositories')
|
||||
url.searchParams.append('q', keyword)
|
||||
url.searchParams.append('page', page.toString())
|
||||
const response = await fetch(url.toString(), { method: 'get' })
|
||||
const result = await response.json()
|
||||
|
||||
return result as RepositorySearchResultList
|
||||
}
|
||||
Reference in New Issue
Block a user