
Security News
npm Introduces minimumReleaseAge and Bulk OIDC Configuration
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.
eprel-client
Advanced tools
Typesafe and straightforward fetch client for interacting with the European Product Registry for Energy Labelling (EPREL) API using feature-fetch
Status: Experimental
eprel-client is a typesafe and straightforward fetch client for interacting with the European Product Registry for Energy Labelling (EPREL) API using feature-fetch.
Use createEPRELClient() to create a client with your API key.
import { createEPRELClient } from 'eprel-client';
const client = createEPRELClient({
apiKey: 'YOUR_API_KEY'
});
Fetches the available product groups from the ERAP API.
const productGroupsResult = await client.getProductGroups();
const productGroups = productGroupsResult.unwrap();
Errors can occur during API requests, and the client will return detailed error information. Possible error types include:
NetworkError: Indicates a failure in network communication, such as loss of connectivityRequestError: Occurs when the server returns a response with a status code indicating an error (e.g., 4xx or 5xx)FetchError: A general exception type that can encompass other error scenarios not covered by NetworkError or RequestError, for example when the response couldn't be parsed, ..const productGroupsResult = await client.getProductGroups();
// First Approach: Handle error using `isErr()`
if (productGroupsResult.isErr()) {
const { error } = productGroupsResult;
if (error instanceof NetworkError) {
console.error('Network error:', error.message);
} else if (error instanceof RequestError) {
console.error('Request error:', error.message, 'Status:', error.status);
} else if (error instanceof FetchError) {
console.error('Service error:', error.message, 'Code:', error.code);
} else {
console.error('Unexpected error:', error);
}
}
// Second Approach: Unwrap response with `try-catch`
try {
const productGroups = productGroupsResult.unwrap();
} catch (error) {
if (error instanceof NetworkError) {
console.error('Network error:', error.message);
} else if (error instanceof RequestError) {
console.error('Request error:', error.message, 'Status:', error.status);
} else if (error instanceof FetchError) {
console.error('Service error:', error.message, 'Code:', error.code);
} else {
console.error('Unexpected error:', error);
}
}
FAQs
Typesafe and straightforward fetch client for interacting with the European Product Registry for Energy Labelling (EPREL) API using feature-fetch
The npm package eprel-client receives a total of 7 weekly downloads. As such, eprel-client popularity was classified as not popular.
We found that eprel-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
npm rolls out a package release cooldown and scalable trusted publishing updates as ecosystem adoption of install safeguards grows.

Security News
AI agents are writing more code than ever, and that's creating new supply chain risks. Feross joins the Risky Business Podcast to break down what that means for open source security.

Research
/Security News
Socket uncovered four malicious NuGet packages targeting ASP.NET apps, using a typosquatted dropper and localhost proxy to steal Identity data and backdoor apps.