# podio-fetch

> Low-level function for making HTTPS requests to the Podio API. See [podio-client](https://www.npmjs.com/package/podio-client) for a higher level interface.

Latest version **3.0.0** (published 2022-09-19) · 0 weekly downloads

## Install

```sh
npm install podio-fetch
pnpm add podio-fetch
yarn add podio-fetch
bun add podio-fetch
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2022-09-19 |
| First published | 2019-04-29 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | thomas-jensen, adomas.d |

## Links

- npm: https://www.npmjs.com/package/podio-fetch
- npm.io page: https://npm.io/package/podio-fetch

## Dependencies (2)

- [json-parse-safe](https://npm.io/package/json-parse-safe.md) ^2.0.0
- [http-querystring-stringify](https://npm.io/package/http-querystring-stringify.md) ^2.1.0

## Recent versions

- 3.0.0 (latest) — 2022-09-19
- 2.0.0 — 2020-05-12
- 1.2.0 — 2020-04-01
- 1.1.0 — 2020-01-25
- 1.0.0 — 2019-04-29

## README

# Podio fetch

Low-level function for making HTTPS requests to the Podio API. See
[podio-client](https://www.npmjs.com/package/podio-client) for a higher level
interface.

```js
const fetch = require('podio-fetch')

fetch({
  fetch = globalThis.fetch,
  log = () => {},
  host = 'https://api.podio.com',
  method = 'GET',
  token,
  path,
  query,

  // one of
  form,
  json,
})
```

## Errors

Some errors are recognized and translated into the following error classes:

```
TokenExpiredError
RateLimitError
UnexpectedHttpStatusError
UnexpectedHttpContentTypeError
InvalidJsonBodyError
```

All of the above will have a `.response` containing the original
[`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) and a
`.body` holding either parsed JSON or text depending on what was possible.

Apart from the above, errors may arise from the underlying engine. For the
built-in `fetch` in Node.js they can be distinguished by `.cause.code` and
include:

```
ECONNRESET
ENOTFOUND
ETIMEDOUT
ECONNREFUSED
EHOSTUNREACH
EPIPE
EAI_AGAIN
```

## Formatting

```js
const {formatPeriod} = require('podio-fetch')
formatPeriod(
  start, // Required. Date object
  end, // Optional. Date object
  utc // Optional, Boolean, defaults to `false`. Set to `true` if the date should be converted to UTC
)
// → {start: 'YYYY-MM-DD HH:MM:SS'} OR {start: 'YYYY-MM-DD HH:MM:SS', end: 'YYYY-MM-DD HH:MM:SS'}
```

**Podio converts the dates based on the authenticated user making the request:**

- If **authenticated as a User**, the dates will be converted to UTC by Podio
  (from timezone in the users settings).
- If **authenticated as an App**, the dates will be treated as UTC (in this case
  you should set `utc` param to `true`).

---
_Source: https://npm.io/package/podio-fetch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
