Guest User

Untitled

a guest
Apr 2nd, 2018
524
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const request = require('request')
  2. module.exports = (user, pass, baseUrl) => {
  3. const client = request.defaults({baseUrl, auth: {user, pass}})
  4.  
  5. const getSomething = (name) => client.get('resources/' + name)
  6. const createSomething = (name, options) => client.post('resources', {...})
  7. return { getSomething, createSomething }
  8. }
  9.  
  10.  
  11. (def request (js/require "request"))
  12.  
  13. (defn make-client [user pass base-url]
  14. (let [client (.defaults request #js {:baseUrl base-url
  15. :auth #js {:user user :pass pass}})
  16. get-something (fn [name] (.get client (str "resources/" name))
  17. create-something (fn [name options] (.post client "resources" {})]
  18. {:get-something get-something
  19. :create-something create-something}))
RAW Paste Data