MCPcopy Create free account
hub / github.com/EsperoTech/yaade / sendRequest

Function sendRequest

extension/background.js:5–29  ·  view source on GitHub ↗
(request, sendResponse, senderUrl)

Source from the content-addressed store, hash-verified

3const websockets = new Map();
4
5async function sendRequest(request, sendResponse, senderUrl) {
6 try {
7 const startTime = Date.now();
8 const options = await buildOptions(request, senderUrl);
9 const response = await fetch(request.url, options);
10 const time = Date.now() - startTime;
11 const body = await response.text();
12 const headers = [...response.headers].map((el) => ({
13 key: el[0],
14 value: el[1],
15 }));
16 sendResponse({
17 metaData: request?.metaData,
18 status: response.status,
19 body,
20 headers,
21 time,
22 });
23 } catch (err) {
24 sendResponse({
25 metaData: request?.metaData,
26 err: err.message
27 });
28 }
29}
30
31async function buildOptions(request, senderUrl) {
32 if (!request.req) {

Callers 1

background.jsFile · 0.70

Calls 2

buildOptionsFunction · 0.85
nowMethod · 0.45

Tested by

no test coverage detected