httpsnippet-client-api

An HTTP Snippet client for generating snippets for the api module.

Usage no npm install needed!

<script type="module">
  import httpsnippetClientApi from 'https://cdn.skypack.dev/httpsnippet-client-api';
</script>

README

httpsnippet-client-api

An HTTP Snippet client for generating snippets for the api module.

npm Build

Installation

npm install --save httpsnippet-client-api

Usage

const httpsnippet = require('httpsnippet');
const client = require('httpsnippet-client-api');

HTTPSnippet.addTargetClient('node', client);

const snippet = new HTTPSnippet(harObject);
console.log(
  snippet.convert('node', 'api', {
    apiDefinitionUri: 'https://example.com/openapi.json'
    apiDefinition: {
      /* an OpenAPI definition object */
    }
  })
);

Results in the following:

const sdk = require('api')('https://example.com/openapi.json');

sdk.get('/har')
  .then(res => console.log(res))
  .catch(err => console.error(err));