Class: Osmosis

Osmosis


new Osmosis(url, params)

Unless called with `new`, Osmosis will start automatically. To start an instance created with `new`, use Osmosis.run.
Parameters:
Name Type Argument Description
url string | contextCallback A URL
params object <optional>
GET query parameters
See:
  • Command.run
Returns:
Command
Example

// These instances start immediately
osmosis.get('http://example.com');
osmosis('http://example.com');

// These instances need started
instance = new osmosis.get('http://example.com');
instance.run();

instance = new osmosis('http://example.com');
instance.run();

Members


options Osmosis and needle options.

Properties:
Name Type Description
accept string HTTP Accept header
compressed bool Compress HTTP requests
concurrency number Number of simultaneous HTTP requests
decode_response bool Decode compressed HTTP responses
follow number Number of redirects to follow
follow_set_cookies bool Set cookies for redirects
follow_set_referer bool Set referer header for redirects
keep_data bool Keep raw HTTP data in context.response.data
timeout bool HTTP request timeout
tries bool HTTP request retries
user_agent bool HTTP user agent

Methods


config(option, value)

Configure global Osmosis options.
Parameters:
Name Type Argument Description
option string | object A string `key` or an object of { key: value } pairs.
value any <optional>
A value for the `key`
See:
  • Command.config
  • Osmosis.options

run()

Run (or re-run) an Osmosis instance. If you frequently use the same Osmosis instance (such as in an Express server), it's much more efficient to initialize the instance once and repeatedly use `run` as needed.
See:
  • Command.run