lematt1991 / untappd-js

Node.js client for the Untappd API
8 stars 2 forks source link

Basic Steps for getting started needed #2

Open penny506 opened 4 days ago

penny506 commented 4 days ago

I have a little bit of node experience, but between getting the 'node install' to trying to get this 'require' syntax to find the index.js, I'm running into many issues that a more seasoned person may know, but I'm having troubles, and I think a 4 line extra in readme would go a long way - thanks!!

penny506 commented 3 days ago

One problem was axios version - I ran: npm audit fix --force Which fixed that

Also More sample code which may help: (used environment vars for keys as: npm install dotenv and created .env at root)


const Untappd = require("./index");
require('dotenv').config();
const client = new Untappd();

client.setClientId(process.env.UNTAPPD_CLIENT_ID)
client.setClientSecret(process.env.UNTAPPD_CLIENT_SECRET);

console.log(client)

const data = {USERNAME:"1234"};

client.userActivityFeed(data)
    .then(data => {
        // Access the check-ins
        const checkins = data.response.checkins.items;

        checkins.forEach(checkin => {
            console.log(`Beer: ${checkin.beer.beer_name} by ${checkin.brewery.brewery_name}`);
            console.log(`${checkin.venue.venue_name} On: ${checkin.created_at}`);
        if( checkin.media.items[0])
                console.log(`With Image:`+checkin.media.items[0].photo.photo_img_sm )
        });
    })
    .catch(err => console.log(err));