How to use the request-compose.client function in request-compose

To help you get started, we’ve selected a few request-compose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simov / grant / examples / jwt / app.js View on Github external
var express = require('express')
var session = require('express-session')
var grant = require('grant-express')
var request = require('request-compose').client
var jwt = require('./jwt')


express()
  .use(session({name: 'grant', secret: 'grant', saveUninitialized: true, resave: true}))
  .use(grant(require('./config.json')))

  .get('/hello', async (req, res) => {
    var {body} = await request({
      url: 'https://graph.facebook.com/v2.12/me',
      headers: {authorization: `Bearer ${req.session.grant.response.access_token}`}
    })
    // remove the session data
    req.session.destroy(() => {
      // remove the cookie
      res.clearCookie('grant')
github simov / grant / test / client.js View on Github external
it('extend', async () => {
      var {body} = await request({url: 'http://localhost:5000/qstext'})
      t.deepStrictEqual(body, {nested: {querystring: 'true'}})
      var {body} = await compose.client({url: 'http://localhost:5000/qstext'})
      t.equal(body, 'nested%5Bquerystring%5D=true')
    })
github simov / request-compose / examples / basic-client.js View on Github external
var request = require('request-compose').client

;(async () => {
  try {
    var {res, body} = await request({
      url: 'https://api.github.com/users/simov',
      headers: {
        'user-agent': 'request-compose'
      }
    })
    console.log(res.statusCode, res.statusMessage)
    console.log(res.headers['x-ratelimit-remaining'])
    console.log(body)
  }
  catch (err) {
    console.error(err)
  }
github simov / request-compose / examples / slack-weather-status.js View on Github external
var compose = require('request-compose')
var request = compose.client

var pipe = ({auth, address}) => compose(
  _ => request({
    url: 'https://maps.googleapis.com/maps/api/geocode/json',
    qs: {key: auth.google, address},
  }),
  ({body: {results: [{geometry: {location}}]}}) => request({
    url: `https://api.darksky.net/forecast/${auth.darksky}/${location.lat},${location.lng}`,
    qs: {exclude: 'minutely,hourly,daily,alerts,flags'},
  }),
  ({body: {currently: {icon}}}) => ({
    'clear-day': 'sunny',
    'clear-night': 'crescent_moon',
    'rain': 'rain_cloud',
    'snow': 'snow_cloud',
    'sleet': 'snowflake',

request-compose

Composable HTTP Client

Apache-2.0
Latest version published 2 months ago

Package Health Score

70 / 100
Full package analysis