open-index/open-npm huggingface dataset:
npm package: @mondopower/fetch
Description: Library to use to wrap node fetch
Latest version: 1.2.2

This package represents an http client library to perform http requests with interceptors, redaction etc.

# Usage #
const client = new FetchClient({authorizationToken, baseUrl})
const result = await client.get('urlpath')

If an error occurred the result will contain an isErrored = true and an error property including a type and a message
if (result.isErrored)
  console.log(result.error.errorType, result.error.message)

otherwise the result will contain the data property

console.log(result.data)
npm package: @mondopower/result-types
Description: Library to use for result type of typescript functions and helper functions.
Latest version: 1.2.2

# Mondo Result Types

Library to use for result type of typescript functions and helper functions.

## Install

```bash
npm i @mondopower/result-types
```

## Usage

This library consists of two major result types.

### 1) ResultVoid

Used whenever the function will return void in the case of success or failure

```ts
import {raiseFailure, raiseSuccessVoid, ResultVoid} from '@mondopower/result-types'

enum FooErrorType {
  someError= 'someError'
  ...
}

function foo(flag: boolean): ResultVoid<FooErrorType> {
  if (flag)
    return raiseFailure({
      errorType: FooErrorType.someError,
      message: '<my error message>'
    })

  return raiseSuccessVoid()
}

const fooResponse = foo(flag)

if (fooResponse.isErrored)
  // Failure Handling
else
  // success handling
```

### 2) Result


Used whenever the function will return a value/object in the case of success or failure

```ts
import {raiseFailure, raiseSuccess, Result} from '@mondopower/result-types'

enum FooErrorType {
  someError= 'someError'
  ...
}

function foo(flag: boolean): Result<string, FooErrorType> {
  if (flag)
    return raiseFailure({
      errorType: FooErrorType.someError,
      message: '<my error message>'
    })

  return raiseSuccess('success-result')
}

const fooResponse = foo(flag)

if (fooResponse.isErrored)
  // Failure Handling
else {
  // success handling
  const result = fooResponse.data
}
```

## Helpers

This library also includes some helper functions to manage success and failures which all can be found in the [API documentation](https://github.com/MondoPower/mondo-common-libs/docs/packages/mondo-result-types).