Skip to content

Commit

Permalink
feat(httpContextProvider): load AC on fetch client (continuedev#1150)
Browse files Browse the repository at this point in the history
Co-authored-by: Bertrand Pinel <[email protected]>
  • Loading branch information
2 people authored and pzaback committed Apr 22, 2024
1 parent f05df63 commit 1879513
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions core/context/providers/HttpContextProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ContextProviderDescription,
ContextProviderExtras,
} from "../..";
import { fetchwithRequestOptions } from "../../util/fetchWithOptions";

class HttpContextProvider extends BaseContextProvider {
static description: ContextProviderDescription = {
Expand All @@ -28,18 +29,21 @@ class HttpContextProvider extends BaseContextProvider {
query: string,
extras: ContextProviderExtras,
): Promise<ContextItem[]> {
const response = await fetch(this.options.url, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
query: query || "",
fullInput: extras.fullInput,
}),
});

const json = await response.json();
const response = await fetchwithRequestOptions(
new URL(this.options.url),
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
query: query || "",
fullInput: extras.fullInput,
}),
}
);

const json: any = await response.json();
return [
{
description: json.description || "HTTP Context Item",
Expand Down

0 comments on commit 1879513

Please sign in to comment.