bartve / disconnect

An easy to use Node.js client with OAuth support to connect with the discogs.com API v2.0
MIT License
458 stars 79 forks source link

Output format doesn't seem to work #44

Open oskarrough opened 6 years ago

oskarrough commented 6 years ago

Hi, I'm trying to use the setConfig method to set the output format but it always returns the "Discogs" format.

const Discogs = require('disconnect').Client
const client = new Discogs().setConfig({outputFormat: 'html'})
const db = client.database()

// Route that fetches the profile of 'Michael Jackson' artist.
// Hopefully it'll be in HTML.
app.get('/', async (req, res) => {
  const data = await db.getArtist('15885')
  res.json(data.profile)
})

Am I doing it wrong? Here's a test case:

bartve commented 6 years ago

Hmm, disconnect does seem to provide the correct header according to https://www.discogs.com/developers/#page:home,header:home-versioning-and-media-types I will have to try without the additional accept headers I provide for plain json and images. Not much time to work on bug unfortunately, so pull requests are welcome!

oskarrough commented 6 years ago

Sure!

I tried without the additional headers but I can't get it to return anything but discogs/bbcode. I wonder if it works at all from the Discogs API or if I'm using the correct syntax?

Failed attempt to get a plain text profile field:

curl -s --header "Accept: application/vnd.discogs.v2.plaintext+json" https://api.discogs.com/artists/15885 

Also asked here https://www.discogs.com/forum/thread/743611?page=1#7615721

oskarrough commented 6 years ago

I found help in the Discogs forum! It turns out that profile field is discogscode no matter the chosen format. Instead you get a new field: profile_html or profile_plaintext respectively.

oskarrough commented 6 years ago

Hi @bartve, I added a pull request to try and clarify how this works and close this out. What do you think?

https://github.com/bartve/disconnect/pull/46