New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@polywrap/http-plugin-js

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@polywrap/http-plugin-js

Polywrap HTTP Javascript Plugin

  • 0.9.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
103
increased by77.59%
Maintainers
2
Weekly downloads
 
Created
Source

@polywrap/http-plugin-js

Http plugin curently 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).

const response = await polywrapClient.invoke<Response>({
  uri: new Uri("wrap://ens/http.polywrap.eth"),
  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.

const response = await polywrapClient.invoke<Response>({
  uri: new Uri("wrap://ens/http.polywrap.eth"),
  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'}"
    }
  }
})

FAQs

Package last updated on 19 Feb 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc