xhr-simple-request

WebJar for xhr-simple-request

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

org.webjars.bowergithub.advanced-rest-client
ArtifactId

ArtifactId

xhr-simple-request
Last Version

Last Version

2.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

xhr-simple-request
WebJar for xhr-simple-request
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/advanced-rest-client/xhr-simple-request

Download xhr-simple-request

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.bowergithub.advanced-rest-client/xhr-simple-request/ -->
<dependency>
    <groupId>org.webjars.bowergithub.advanced-rest-client</groupId>
    <artifactId>xhr-simple-request</artifactId>
    <version>2.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.bowergithub.advanced-rest-client/xhr-simple-request/
implementation 'org.webjars.bowergithub.advanced-rest-client:xhr-simple-request:2.0.3'
// https://jarcasting.com/artifacts/org.webjars.bowergithub.advanced-rest-client/xhr-simple-request/
implementation ("org.webjars.bowergithub.advanced-rest-client:xhr-simple-request:2.0.3")
'org.webjars.bowergithub.advanced-rest-client:xhr-simple-request:jar:2.0.3'
<dependency org="org.webjars.bowergithub.advanced-rest-client" name="xhr-simple-request" rev="2.0.3">
  <artifact name="xhr-simple-request" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.bowergithub.advanced-rest-client', module='xhr-simple-request', version='2.0.3')
)
libraryDependencies += "org.webjars.bowergithub.advanced-rest-client" % "xhr-simple-request" % "2.0.3"
[org.webjars.bowergithub.advanced-rest-client/xhr-simple-request "2.0.3"]

Dependencies

compile (3)

Group / Artifact Type Version
org.webjars.bowergithub.polymer : polymer jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client : headers-parser-behavior jar [2.0.0,3)
org.webjars.bowergithub.advanced-rest-client » events-target-behavior jar [2.0.0,3)

Project Modules

There are no modules declared in this project.

Published on NPM

Build Status

Published on webcomponents.org

<xhr-simple-request>

An XHR request that works with API components.

It handles api-request and abort-api-request custom events that controls request flow in API components ecosystem.

<xhr-simple-request></xhr-simple-request>

Deprecation notice

This component has been moved to api-request. Once the new version of API Console is released this project will be archived.

Usage

Installation

npm install --save @advanced-rest-client/xhr-simple-request

In an html file

<html>
  <head>
    <script type="module">
      import '@advanced-rest-client/xhr-simple-request/xhr-simple-request.js';
    </script>
  </head>
  <body>
    <xhr-simple-request></xhr-simple-request>
    <script>
    const request = {
      url: location.href,
      method: 'POST',
      headers: 'x-arc: true',
      payload: 'test body',
      id: 'request-unique-id'
    };
    const e = new CustomEvent('api-request', {
      detail: request,
      bubbles: true
    });
    document.body.dispatchEvent(e);
    window.addEventListener('api-response', (e) => {
      console.log(e.detail);
    });
    </script>
  </body>
</html>

In a LitElement template

import { LitElement, html } from 'lit-element';
import '@advanced-rest-client/xhr-simple-request/xhr-simple-request.js';

class SampleElement extends LitElement {
  render() {
    return html`
    <xhr-simple-request @api-response="${this._onResponse}"></xhr-simple-request>`;
  }

  _onResponse(e) {
    console.log(e.detail);
  }
}
customElements.define('sample-element', SampleElement);

In a Polymer 3 element

import {PolymerElement, html} from '@polymer/polymer';
import '@advanced-rest-client/xhr-simple-request/xhr-simple-request.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
    <xhr-simple-request on-api-response="_onResponse"></xhr-simple-request>
    `;
  }

  send() {
    const request = {
      url: location.href,
      method: 'POST',
      headers: 'x-arc: true',
      payload: 'test body',
      id: 'request-unique-id'
    };
    const e = new CustomEvent('api-request', {
      detail: request,
      bubbles: true
    });
    document.body.dispatchEvent(e);
  }

  _onResponse(e) {
    console.log(e.detail);
  }
}
customElements.define('sample-element', SampleElement);

Development

git clone https://github.com/advanced-rest-client/xhr-simple-request
cd xhr-simple-request
npm install

Running the demo locally

npm start

Running the tests

npm test
org.webjars.bowergithub.advanced-rest-client

ARC

A set of repositories related to the Advanced REST Client and API console (by Mulesoft)

Versions

Version
2.0.3