Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/flawiddsouza/httpsnippet-browser


https://github.com/flawiddsouza/httpsnippet-browser

Last synced: about 11 hours ago
JSON representation

Awesome Lists containing this project

README

        

## Install

```sh
npm install https://github.com/flawiddsouza/httpsnippet-browser
```

## Usage

```js
import { HTTPSnippet } from 'httpsnippet-browser'

const har = {
method: 'POST',
url: 'https://postman-echo.com/post',
headers: [
{
name: 'Content-Type',
value: 'application/json'
}
],
postData: {
mimeType: 'application/json',
text: '{"foo": "bar"}'
}
}

const snippet = new HTTPSnippet(har)

const output = snippet.convert('shell', 'curl', {
indent: ' '
})

console.log(output)
// curl --request POST \
// --url https://postman-echo.com/post \
// --header 'Content-Type: application/json' \
// --data '{"foo": "bar"}'
```