Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "client"

Index

Functions

createAPIUrl

createClient

  • createClient(apiToken: string, requestConfig?: AxiosRequestConfig): DarkSkyClient
  • Default implementation of ClientFactory for making authorized requests to the DarkSky API.

    Note: Get your token from https://darksky.net/dev/account.

    Parameters

    • apiToken: string

      Developer API token.

    • Default value requestConfig: AxiosRequestConfig = {}

      Optional config to change the way axios makes the request.

    Returns DarkSkyClient

    Client for interacting with the API.

createQueryParams

  • Takes a params object and converts it to an HTTP query parameters string.

    const params: RequestParams = { exclude: ['hourly', 'daily'], lang: 'en' }
    const query: string = createQueryParams(params)
    // query = '?exclude=hourly,daily&lang=en'

    Parameters

    • obj: RequestParams

      Params object to convert into Query parameters.

    Returns string

    A query parameter string.

doRequest

  • Make the API request, and add the response headers to the result.

    Type parameters

    • R: Forecast

      Type of response that extends Forecast.

    Parameters

    • apiToken: string

      Developer API token.

    • request: ForecastRequest

      Forecast request data.

    • params: RequestParams

      Optional query params to add to the request.

    • requestConfig: AxiosRequestConfig

      Optional config to change the way axios makes the request.

    Returns Promise<R>

    Forecast response with the HTTP headers.

Generated using TypeDoc