0.0.5 • Published 8 years ago
mindbrain v0.0.5
Mindbrain API client
Client for the Mindbrain HTTP API
Documentation: https://api.mindbrainmusic.com
Installation
yarn add mindbrainUsage
Import the Mindbrain client from the mindbrain package, load in your
artist name configuration, and you can start using the get() method
right away:
import Mindbrain from 'mindbrain'
import config from './package.json'
const mindbrain = new Mindbrain(config)
mindbrain.get('releases').then(releases => console.log(releases))This will make an HTTP GET request to
https://api.mindbrainmusic.com/artists/your-artist-name/releases.json,
which retrieves all of the releases for a given artist. The get() method
performs an HTTP GET request on the given resource passed in, and returns
a Promise object that you can either tack on additional methods to, or use
the async / await syntax like so:
import React from 'react'
import Mindbrain from 'mindbrain'
class App extends React.Component {
this.mindbrain = new Mindbrain({ name: 'wonderbars' })
async componentWillMount() {
let releases = await this.mindbrain.get('releases')
this.setState({ releases })
}
// ...
}