Thin Fetch API client for the Steam Web API
$ npm install --save steam-web-api-fetch babel isomorphic-fetch
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] ] } }
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.