0.0.1 • Published 9 years ago

steam-web-api-fetch v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 years ago

steam-web-api-fetch

Thin Fetch API client for the Steam Web API

Travis build status Code Climate Test Coverage Dependency Status devDependency Status

Install

$ npm install --save steam-web-api-fetch babel isomorphic-fetch

Usage

require('babel/polyfill')
require('isomorphic-fetch')
var steamWebApiFetch = require('steam-web-api-fetch').default

steamWebApiFetch('SteamNews', 'GetNewsForApp', {
  version: 2,
  query: {
    appid: 440,
    count: 3,
    maxlength: 300
  }
}) // GET https://api.steampowered.com/ISteamNews/GetNewsForApp/v0002/?appid=440&count=3&maxlength=300&format=json
  .then(function (res) {
    if (res.status >= 400) {
      return Promise.reject(res)
    }
    return res.json()
  })
  .then(function (body) {
    console.log(body)
  }) // { appnews: { appid: 440, newsitems: [ [Object], [Object], [Object] ] } }

API

default(interfaceName, methodName, options)

See steam-web-api-build-url for information about interfaceName, methodName, and options. Options not listed in steam-web-api-build-url will be passed to fetch.