# flow-api-component

> Components to make requests to an endpoint designed to work with Flow SDK

Latest version **0.3.3** (published 2019-06-19) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install flow-api-component
pnpm add flow-api-component
yarn add flow-api-component
bun add flow-api-component
```

## 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.3.3 |
| Published | 2019-06-19 |
| First published | 2018-12-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 45.3 KB |
| Known vulnerabilities | 0 (+24 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hackerbay Inc. |
| Maintainers | hackerbayadmin |
| Keywords | flow, api |

## Links

- npm: https://www.npmjs.com/package/flow-api-component
- Repository: https://github.com/FlowAppPlatform/flow-api-component
- Homepage: https://github.com/FlowAppPlatform/flow-api-component#readme
- Issues: https://github.com/FlowAppPlatform/flow-api-component/issues
- npm.io page: https://npm.io/package/flow-api-component

## Dependencies (5)

- [axios](https://npm.io/package/axios.md) ^0.18.0
- [mocha](https://npm.io/package/mocha.md) ^5.2.0
- [eslint](https://npm.io/package/eslint.md) ^5.4.0
- [cross-env](https://npm.io/package/cross-env.md) ^5.2.0
- [flow-platform-sdk](https://npm.io/package/flow-platform-sdk.md) ^1.3.1

## Recent versions

- 0.3.3 (latest) — 2019-06-19
- 0.3.1 — 2019-03-10
- 0.2.9 — 2019-02-15
- 0.2.7 — 2018-12-26

## README

# Flow API component
The component makes API requests and is designed to work with Flow SDK

*To get started, install the package in your NodeJS project*

```
npm i flow-api-component --save
```

*Use the component as below*

```javascript
// require the component
const Component = require('flow-api-component');

// create instance of the GET component for example
const component = new Component.GET();
```

*Provide url, headers and any data to pass*

```javascript
component.getProperty('URL').data = 'https://www.google.com/';
component.getProperty('Headers').data = {
  'X-Requested-With': 'XMLHttpRequest'
};
component.getProperty('Data').data = {
  'q': 'home'
};
```

*Listen in for port emit events*
```javascript
component.getPort('Complete').onEmit(function() {
  // request was successfully made
  const port = this.getPort('Complete');
  // the response can be accessed through properties of the port
  const statusCode = port.getProperty('StatusCode').data;
  const statusText = port.getProperty('StatusText').data;
  const responseHeaders = port.getProperty('Headers').data;
  const responseData = port.getProperty('Data').data;
  // or the whole response object
  const response = port.getProperty('Response').data;
});

component.getPort('Failed').onEmit(function() {
  // an error occured
  // the actual error can be accessed through the 'Data' property of the port
  let err = component.getPort('Failed').getProperty('Data').data;
});
```

*Execute the component*
```javascript
// add the component to a graph before executing it
const Graph = require('flow-platform-sdk').Graph;
new Graph("graph-1").addComponent(component);

component.execute();
```

#### Conclusion

That's the Flow API GET component. Also check, the [POST](./docs/components/post.md), [PUT](./docs/components/put.md), [DELETE](./docs/components/delete.md)  components.

---
_Source: https://npm.io/package/flow-api-component · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
