# @polywrap/http-plugin-js

> Polywrap HTTP Javascript Plugin

Latest version **0.12.0** (published 2023-08-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @polywrap/http-plugin-js
pnpm add @polywrap/http-plugin-js
yarn add @polywrap/http-plugin-js
bun add @polywrap/http-plugin-js
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.12.0 |
| Published | 2023-08-20 |
| First published | 2022-06-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 44.3 KB |
| Known vulnerabilities | 0 (+25 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 168 |
| Maintainers | polywrap-build-bot, dorgjelli |

## Links

- npm: https://www.npmjs.com/package/@polywrap/http-plugin-js
- Repository: https://github.com/polywrap/monorepo
- npm.io page: https://npm.io/package/@polywrap/http-plugin-js

## Dependencies (4)

- [axios](https://npm.io/package/axios.md) 0.21.4
- [form-data](https://npm.io/package/form-data.md) 4.0.0
- [@polywrap/core-js](https://npm.io/package/@polywrap/core-js.md) ~0.12.0
- [@polywrap/plugin-js](https://npm.io/package/@polywrap/plugin-js.md) ~0.12.0

## Recent versions

- 0.12.0 (latest) — 2023-08-20
- 0.12.0-pre.0 (pre) — 2023-07-26
- 0.10.0 — 2023-04-27
- 0.9.7 — 2023-03-28
- 0.10.0-pre.10 — 2023-03-04
- 0.10.0-pre.8 — 2023-03-03
- 0.9.6 — 2023-02-19
- 0.9.5 — 2023-02-10
- 0.10.0-pre.7 — 2023-01-11
- 0.10.0-pre.6 — 2022-12-20
- 0.10.0-pre.5 — 2022-11-22
- 0.10.0-pre.4 — 2022-11-16
- 0.10.0-pre.3 — 2022-11-13
- 0.10.0-pre.1 — 2022-11-12
- 0.10.0-pre.0 — 2022-11-05
- … 23 more at https://npm.io/package/@polywrap/http-plugin-js/versions

## README

# @polywrap/http-plugin-js

Http plugin currently supports two different methods `GET` and `POST`. Similar to calling axios, when defining request you need to specify a response type. Headers and query parameters may also be defined.

## Response Types

`TEXT` - The server will respond with text, the HTTP plugin will return the text as-is.

`BINARY` - The server will respond with binary data (_ArrayBuffer_), the HTTP plugin will encode as a **base64** string and return it.

## GET request

Below is sample invocation of the `GET` request with custom request headers and query parameters (`urlParams`).

```ts
const result = await client.invoke<Response>({
  uri: "wrapscan.io/polywrap/http@1.0",
  method: "get",
  args: {
    url: "http://www.example.com/api",
    request: {
      responseType: "TEXT",
      urlParams: [{key: "query", value: "foo"}],
      headers: [{key: "X-Request-Header", value: "req-foo"}],
    }
  }
})
```

## POST request

Below is sample invocation of the `POST` request with custom request headers and query parameters (`urlParams`). It is also possible to set request body as shown below.

```ts
const response = await polywrapClient.invoke<Response>({
  uri: "wrapscan.io/polywrap/http@1.0",
  method: "post",
  args: {
    url: "http://www.example.com/api",
    request: {
      responseType: "TEXT",
      urlParams: [{key: "query", value: "foo"}],
      headers: [{key: "X-Request-Header", value: "req-foo"}],
      body: "{data: 'test-request'}",
    }
  }
})
```

---
_Source: https://npm.io/package/@polywrap/http-plugin-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
