Skip to content

Commit

Permalink
Merge pull request #5 from fetimo/main
Browse files Browse the repository at this point in the history
Remove undici shim
  • Loading branch information
Hexagon authored May 29, 2023
2 parents 9f09427 + 2130ec3 commit 1bcf368
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { QueryConfiguration } from "https://deno.land/x/entsoe_api_client/mod.ts
npm install entsoe-api-client --save
```

### Note
Using an older version of Node.js? Use 0.x versions of this library for fetch compatibility.

## Documentation

Expand Down
1 change: 0 additions & 1 deletion scripts/build_npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ await build({
outDir: "./npm",
shims: {
deno: "dev",
undici: true // Undici is for fetch support in old node versions
},
mappings: {
"https://deno.land/x/zipjs@v2.6.63/index.js": {
Expand Down
4 changes: 4 additions & 0 deletions src/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const Query = async (securityToken: string, params: QueryParameters): Promise<(P
const query = ComposeQuery(securityToken, params);

// Construct url and get result
// @ts-expect-error fetch is not recognised as a valid global.
const result = await fetch(`${ENTSOE_ENDPOINT}?${query}`);

// Check for 401
Expand All @@ -282,6 +283,9 @@ const Query = async (securityToken: string, params: QueryParameters): Promise<(P
for (const xmlFileEntry of await zipReader.getEntries()) {
// Unzip file
const stringDataWriter = new TextWriter();

if (typeof xmlFileEntry.getData !== "function") break;

await xmlFileEntry.getData(stringDataWriter);
const xmlFileData = await stringDataWriter.getData();

Expand Down

0 comments on commit 1bcf368

Please sign in to comment.