# Class: NodeApiClient

## NodeApiClient

#### new NodeApiClient()

The NodeApiClient class.

Source:
  - NodeApiClient.js, line 21

### Methods

- (static) rootPath(valopt) → {*}
- init(core)
- server(host, port)
- session(key, obj)
- sync(collectionInstance, path, query, options, callback)

#### (static) rootPath(valopt) → {*}

Gets / sets the rootPath for the client to use in each API call.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`val` | String | <optional> | The path to set.

Source:
  - NodeApiClient.js, line 46

##### Returns:

Type
  *

#### init(core)

The init method that can be overridden or extended.

##### Parameters:

Name | Type | Description
--- | --- | ---
`core` | Core | The ForerunnerDB core instance.

Source:
  - NodeApiClient.js, line 29

#### server(host, port)

Set the url of the server to use for API.

##### Parameters:

Name | Type | Description
--- | --- | ---
`host` | String | The server host name including protocol. E.g. "https://0.0.0.0".
`port` | String | The server port number e.g. "8080".

Source:
  - NodeApiClient.js, line 61

#### session(key, obj)

Gets/ sets a global object that will be sent up with client requests to the API or REST server.

##### Parameters:

Name | Type | Description
--- | --- | ---
`key` | String | The key to send the session object up inside.
`obj` | * | The object / value to send up with all requests. If a request has its own data to send up, this session data will be mixed in to the request data under the specified key.

Source:
  - NodeApiClient.js, line 300

#### sync(collectionInstance, path, query, options, callback)

Initiates a client connection to the API server.

##### Parameters:

Name | Type | Description
--- | --- | ---
`collectionInstance` |  |
`path` |  |
`query` |  |
`options` |  |
`callback` |  |

Source:
  - NodeApiClient.js, line 320