Skip to content

Commit c4d6c17

Browse files
fix: Loaded endpoint request fix
1 parent 05214dc commit c4d6c17

File tree

4 files changed

+10
-42
lines changed

4 files changed

+10
-42
lines changed

extensions/src/SidebarProvider.ts

+3-12
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
1616
private apiHistory: ApiEndpoint[] = [];
1717
private showHistory: boolean = false;
1818
private context: vscode.ExtensionContext;
19-
private apiRequestView: ApiRequestView;
2019
private httpClient: HttpClient;
2120

2221
constructor(private readonly _extensionUri: vscode.Uri, context: vscode.ExtensionContext) {
2322
this.apiRequestProvider = new ApiRequestProvider(context);
2423
this.context = context;
2524
this.loadApiHistory();
2625
this.httpClient = new HttpClient();
27-
this.apiRequestView = new ApiRequestView(context, this.httpClient.sendRequest.bind(this.httpClient));
2826

2927
// Add these lines to the constructor
3028
this.inspectApiHistory();
@@ -108,36 +106,31 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
108106
break;
109107
}
110108
case "openApiManagement": {
111-
console.log("API MANAGEMENT CASE");
109+
112110
if (!data.value) {
113111
return;
114112
}
115113
this.openWebview(data.value);
116114
break;
117115
}
118116
case "backButton": {
119-
console.log("Going Back");
120117
this.showHistory = false;
121118
this.refresh();
122119
break;
123120
}
124121
case "newRequest": {
125-
console.log("New request log");
126122
this.openApiRequestView();
127123
break;
128124
}
129125
case "deleteEndpoint": {
130-
console.log("Deleting endpoint");
131126
this.deleteEndpoint(data.name, data.method);
132127
break;
133128
}
134129
case "selectEndpoint": {
135-
console.log("Selection endpoint");
136130
this.loadEndpoint(data.value);
137131
break;
138132
}
139133
case "exportHistory": {
140-
console.log("Export history");
141134
this.exportHistory();
142135
break;
143136
}
@@ -226,7 +219,6 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
226219
private async openWebview(webviewType: string) {
227220
if (webviewType === 'apiManagement') {
228221
if (this.apiRequestProvider) {
229-
console.log("Opening API Request View");
230222
this.apiRequestProvider.openApiRequestView();
231223
this.showHistory = true;
232224
this.refresh();
@@ -251,7 +243,6 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
251243

252244
private openApiRequestView() {
253245
if (this.apiRequestProvider) {
254-
console.log("Opening API Request View");
255246
this.apiRequestProvider.openApiRequestView();
256247
} else {
257248
console.error("apiRequestProvider is not initialized");
@@ -348,8 +339,8 @@ export class SidebarProvider implements vscode.WebviewViewProvider {
348339
private loadEndpoint(endpoint: { method: string, name: string }) {
349340
const savedEndpoint = this.apiHistory.find(e => e.method === endpoint.method && e.name === endpoint.name);
350341
if (savedEndpoint) {
351-
this.apiRequestView.show();
352-
this.apiRequestView.loadEndpoint(savedEndpoint);
342+
this.apiRequestProvider.openApiRequestView();
343+
this.apiRequestProvider.loadEndpoint(savedEndpoint);
353344
}
354345
}
355346
}

extensions/src/apiRequest/apiRequestProvider.ts

+7-20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as vscode from "vscode";
22
import { ApiRequestView } from "./apiRequestView";
33
import { HttpClient } from "../utils/httpClient";
4+
import { ApiEndpoint } from "../types";
45

56
interface Collection {
67
name: string;
@@ -31,7 +32,6 @@ export class ApiRequestProvider {
3132
}
3233

3334
public openApiRequestView() {
34-
console.log("API Request View : This is the request view");
3535
this.view = new ApiRequestView(this.context, this.handleApiRequest);
3636
this.view.show();
3737
this.updateCollectionsView();
@@ -46,18 +46,6 @@ export class ApiRequestProvider {
4646
body: string,
4747
bodyType: string
4848
): Promise<void> {
49-
console.log("Handle API Request called");
50-
51-
// Log the incoming parameters
52-
console.log("Parameters:", {
53-
method,
54-
url,
55-
headers,
56-
queryParams,
57-
formData,
58-
body,
59-
bodyType,
60-
});
6149

6250
let urlObj: URL;
6351

@@ -97,13 +85,6 @@ export class ApiRequestProvider {
9785
requestBody = body;
9886
}
9987

100-
console.log("Final Request:", {
101-
url: urlObj.toString(),
102-
method,
103-
headers,
104-
requestBody,
105-
});
106-
10788
const startTime = Date.now();
10889

10990
try {
@@ -181,4 +162,10 @@ export class ApiRequestProvider {
181162
private saveEnvironment() {
182163
this.context.globalState.update("apiEnvironment", this.environment);
183164
}
165+
166+
public loadEndpoint(endpoint: ApiEndpoint) {
167+
if (this.view) {
168+
this.view.loadEndpoint(endpoint);
169+
}
170+
}
184171
}

extensions/src/apiRequest/apiRequestView.ts

-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export class ApiRequestView {
2525
}
2626

2727
public async show() {
28-
console.log("Show from View");
2928
this.panel = vscode.window.createWebviewPanel(
3029
'apiRequest',
3130
'API Request',
@@ -36,7 +35,6 @@ export class ApiRequestView {
3635
}
3736
);
3837
const content = await this.getWebviewContent();
39-
console.log("Webview Content:", content);
4038
this.panel.webview.html = content;
4139

4240
this.panel.webview.onDidReceiveMessage(
@@ -95,13 +93,11 @@ export class ApiRequestView {
9593
}
9694

9795
public loadEndpoint(endpoint: ApiEndpoint) {
98-
console.log("Loading Endpoint");
9996
if (this.panel) {
10097
this.panel.webview.postMessage({
10198
command: 'loadEndpoint',
10299
endpoint: endpoint
103100
});
104-
console.log(this.panel.webview.postMessage);
105101
}
106102
}
107103

extensions/src/utils/httpClient.ts

-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
export class HttpClient {
22
public async sendRequest(url: string, method: string, headers: Record<string, string>, body?: string | FormData) {
33
console.log("Request sent from https client");
4-
console.log('Sending Request:',{url, method}); // Exclude headers and body from logs
5-
64
try {
75
const options: RequestInit = {
86
method,
@@ -19,18 +17,14 @@ console.log('Sending Request:',{url, method}); // Exclude headers and body from
1917
}
2018
}
2119

22-
console.log("Request Options:", options);
23-
2420
const response = await fetch(url, options);
25-
console.log("Response received:", response);
2621

2722
const responseHeaders: Record<string, string> = {};
2823
response.headers.forEach((value, key) => {
2924
responseHeaders[key] = value;
3025
});
3126

3227
const responseBody = await response.text(); // Get the response body as text
33-
console.log("Response Body:", responseBody);
3428

3529
return {
3630
status: response.status,

0 commit comments

Comments
 (0)