3.0.0 • Published 2 years ago

podio-fetch v3.0.0

Weekly downloads
20
License
-
Repository
-
Last release
2 years ago

Podio fetch

Low-level function for making HTTPS requests to the Podio API. See podio-client for a higher level interface.

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 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

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).
3.0.0

2 years ago

2.0.0

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.0

5 years ago