From ce25ae6cdb1cd74eac9c7da29cfd0f5bef7f4773 Mon Sep 17 00:00:00 2001 From: Romes Date: Thu, 4 Feb 2021 18:16:44 +0000 Subject: [PATCH] add example to README I feel that it would be helpful to have some examples like this one on the README. I had to go through some issues to figure out how to search the database. This is a small example I tested successfully --- README.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d63c5e0..8068865 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,32 @@ db.getRelease(176126, function(err, data){ }); ``` +## Examples + +Searching discogs for a cover image + +```javascript +var Discogs = require('disconnect').Client; + +var db = new Discogs({userToken: 'YOUR_USER_TOKEN'}).database(); + +db.search({artist: "Blonde Redhead", release_title: "Misery Is A Butterfly", type: "master"}) + .then(function (searchResult) { + + if (searchResult.results.length > 0) { + + console.log("Found an album cover!"); + console.log("URL: " + searchResult.results[0].cover_image) + } + else + console.log("No album cover was found.") + + }) + .catch(function (err) { + console.error("Error: " + err); + }); +``` + ## Resources * [Discogs API documentation](http://www.discogs.com/developers/) @@ -177,4 +203,4 @@ db.getRelease(176126, function(err, data){ ## License -MIT \ No newline at end of file +MIT