🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

@gigwage/client

Package Overview
Dependencies
Maintainers
4
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gigwage/client

Node client library for accessing the Gig Wage API

Source
npmnpm
Version
1.1.1
Version published
Weekly downloads
93
1228.57%
Maintainers
4
Weekly downloads
 
Created
Source

@gigwage/client

Node client library for accessing the Gig Wage API.

Installation

NPM

npm i @gigwage/client

Yarn

yarn add @gigwage/client

Usage

Create a new Gig Wage client and use it to access APIs from the documentation. The client is used to automatically handle the complex API authentication.

import { createGigwageClient } from "@gigwage/client";
// consider using `dotenv` to pull in environmental variables from a .env file
import "dotenv/config";


// Create a new client
const client = createGigwageClient({
  apiKey: process.env.GIGWAGE_API_KEY,
  apiSecret: process.env.GIGWAGE_SECRET,
});


// Call endpoints from the Gig Wage API using this client.
const response = await client.get("/api/v1/contractors")

// Pass the payload for the second argument for POST and PATCH methods.
const postResponse = await client.post("/api/v1/contractors",{/** new contractor payload*/})

Accessing Response Data

@gigwage/client uses axios under the hood, so all HTTP method responses will return the same format as an axios response would.

try{
  const response = await client.get("/api/v1/contractors")
 
  response.data.contractors // array of contractors

}catch(e){
  // error
}

Using Typescript

Types are included with this package, but the individual API calls are to be included in a future release. For now, you can pass the expected response data type as a generic.

const response = await client.get<{contractors:[]}>("/api/v1/contractors")

Array.isArray(response.data.contractors) // true

FAQs

Package last updated on 17 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts