mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 22:40:01 -04:00
fix bug with headers object and request objects passed into fetch
This commit is contained in:
parent
754b211c59
commit
3c1a942501
2 changed files with 17 additions and 6 deletions
|
@ -1,5 +1,13 @@
|
|||
async function test() {
|
||||
//regular fetch
|
||||
let r = await libcurl.fetch("https://example.com/");
|
||||
assert(r.status === 200, "wrong status");
|
||||
await r.text();
|
||||
|
||||
//fetch with request object
|
||||
let options = {headers: new Headers({"x-test-header": "1"})};
|
||||
let r2 = await libcurl.fetch(new Request("https://httpbin.org/get", options));
|
||||
assert(r2.status === 200, "wrong status");
|
||||
let r2_json = await r2.json();
|
||||
assert(r2_json.headers["X-Test-Header"] === "1");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue