0.2.1 • Published 7 years ago

@colorfulcompany/gas-http-client v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

GasHttpClient

Simple Google Apps Script UrlFetchApp wrapper supporting message authentication with KaleoJWT

KaleoSoftware/KaleoJWT: Super simple, portable JWT implementation that supports only SHA256 algo

feature

  • request()
  • requestJSON()

Usage

import GasHttpClient from 'gas-http-client'

let client = new GasHttpClient(UrlFetchApp, 'https://example.com')
client.opts({
  method:  'post',
  payload: {
    thank: 'you',
    very:  'mutch',
    exp:   new Date('2017-07-22').getTime()
  },
  withJWT: {
    'secret':      'abc',
    'headerField': 'X-GAS-JWT',
  }
})

let response = client.requestJSON('/post')

Note: requestJSON() add header Accept: application/json and Content-Type: application/json automatically.

You can use opts(), headers() and buildParam() or buildParamJSON() for tesing of building HTTP request, without deploying to Google Apps Script to do real HTTP request.