You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, quickjs supportspopen function. But when I added a js module file that uses this function for test purpose, it's not executed and no error is thrown. Do you have any idea? Thanks.
import * as std from 'std';
function fetchPolyfill(resource, init) {
init = init || {
method: 'GET',
headers: null,
body: null,
};
init.method = init.method.toUpperCase();
// curl command
let curlCmd = `curl -s -X${init.method.toUpperCase()} "${resource}"`;
if (init.headers != null && Object.keys(init.headers).length > 0) {
curlCmd = `${curlCmd} ${Object.entries(init.headers).map(n => `-H '${n[0]}: ${n[1]}'`).join(' ')}`
}
if (init.method != 'GET') {
let body = init.body;
if (typeof body != 'string') {
body = JSON.stringify(body);
}
curlCmd = `${curlCmd} -d '${body}'`
}
const spErr = {};
const sp = std.popen(curlCmd, 'r', spErr);
const curlOutput = sp.readAsString();
const responseUrl = resource;
const responseHeaders = {};
let responseOk = true;
let responseStatus = 200;
const p = new Promise((resolve, reject) => {
const response = {
headers: responseHeaders,
ok: responseOk,
url: responseUrl,
type: 'json',
text: () => curlOutput,
json: () => JSON.parse(curlOutput),
};
resolve(response);
});
return p;
}
export default fetchPolyfill;
The text was updated successfully, but these errors were encountered:
Hi, quickjs supports
popen
function. But when I added a js module file that uses this function for test purpose, it's not executed and no error is thrown. Do you have any idea? Thanks.The text was updated successfully, but these errors were encountered: