@advanced-rest-client/http-code-snippets

Code snippets to display a snippets of making a HTTP request

Usage no npm install needed!

<script type="module">
  import advancedRestClientHttpCodeSnippets from 'https://cdn.skypack.dev/@advanced-rest-client/http-code-snippets';
</script>

README

Published on NPM

<http-code-snippets>

Code snippets to render code implementation examples for a HTTP request.

Example:

<http-code-snippets url="https://api.github.com/authorizations" method="POST" payload='{"scopes": ["public_repo"]}'></http-code-snippets>

API components

This components is a part of API components ecosystem

Usage

Installation

npm install --save @advanced-rest-client/http-code-snippets

In an html file

<html>
  <head>
    <script type="module">
      import './node_modules/@advanced-rest-client/http-code-snippets/http-code-snippets.js';
    </script>
  </head>
  <body>
    <http-code-snippets url="https://api.github.com/authorizations" method="POST" payload='{"scopes": ["public_repo"]}'></http-code-snippets>
  </body>
</html>

In a LitElement

import { LitElement, html } from 'lit-element';
import '@advanced-rest-client/http-code-snippets/http-code-snippets.js';

class SampleElement extends PolymerElement {
  render() {
    const {
      url,
      method,
      headers,
      payload
    } = this;
    return html`
    <http-code-snippets
      .url="${url}"
      .method="${method}"
      .headers="${headers}"
      .payload="${payload}"></http-code-snippets>
    `;
  }
}
customElements.define('sample-element', SampleElement);

Development

git clone https://github.com/advanced-rest-client/http-code-snippets
cd http-code-snippets
npm install

Running the demo locally

npm start

Running the tests

npm test