mirror of
https://github.com/nathonius/obsidian-github-link.git
synced 2026-07-22 09:20:25 +00:00
✨ feat: Use real API queries
No more sample data.
This commit is contained in:
parent
35855e204e
commit
25b5b799df
4 changed files with 14 additions and 4179 deletions
|
|
@ -3,6 +3,8 @@ import type { CodeResponse, IssueResponse, PullResponse, SearchIssueResponse, Se
|
|||
import type { RequestUrlParam } from "obsidian";
|
||||
import { requestUrl } from "obsidian";
|
||||
|
||||
const debug = false;
|
||||
|
||||
const baseApi = "https://api.github.com";
|
||||
|
||||
async function githubRequest(config: RequestUrlParam, token?: string) {
|
||||
|
|
@ -14,8 +16,14 @@ async function githubRequest(config: RequestUrlParam, token?: string) {
|
|||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
if (debug) {
|
||||
console.log(config);
|
||||
}
|
||||
try {
|
||||
const response = await requestUrl(config);
|
||||
if (debug) {
|
||||
console.log(response);
|
||||
}
|
||||
return response;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { type MarkdownPostProcessorContext } from "obsidian";
|
||||
import { isTableParams, processParams } from "./params";
|
||||
import samplePRResponse from "./samplePRResponse";
|
||||
import { isPullRequestParams, isTableParams, processParams } from "./params";
|
||||
import { renderTable } from "./output";
|
||||
import type { SearchIssueResponse } from "src/github/response";
|
||||
import { searchIssues } from "src/github/github";
|
||||
|
||||
export async function QueryProcessor(
|
||||
source: string,
|
||||
|
|
@ -17,9 +16,10 @@ export async function QueryProcessor(
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO: Get result
|
||||
|
||||
if (isTableParams(params)) {
|
||||
renderTable(params, samplePRResponse as SearchIssueResponse, el);
|
||||
if (isPullRequestParams(params)) {
|
||||
const response = await searchIssues(params.query);
|
||||
renderTable(params, response, el);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue