Fix data parsing
This commit is contained in:
@@ -39,12 +39,21 @@ export default class GiteaEngine {
|
||||
|
||||
const response = await doFetch(`${this.giteaSearchUrl}?q=${encodeURIComponent(query)}&page=${encodeURIComponent(page)}`, {headers: headers})
|
||||
context?.sentinel?.(response, name)
|
||||
const data = await response.json()
|
||||
return data.map((r) => ({
|
||||
const response_json = await response.json()
|
||||
|
||||
if (response_json.ok != true) {
|
||||
throw context.engineError(
|
||||
"Gitea failure",
|
||||
`${this.name} returned a nok response.`,
|
||||
{ engine: this.name },
|
||||
);
|
||||
}
|
||||
|
||||
return response_json.data.map((r) => ({
|
||||
title: r.full_name,
|
||||
url: r.html_url,
|
||||
snippet: r.description ?? "",
|
||||
source: "Gitea",
|
||||
source: this.name,
|
||||
...(r.avatar_url ? { thumbnail: r.avatar_url } : {}),
|
||||
}));
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user