Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechesser committed Oct 25, 2019
1 parent 35fad09 commit 319fa55
Showing 1 changed file with 1 addition and 80 deletions.
81 changes: 1 addition & 80 deletions examples/node/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,14 @@ import config from 'universal-config';
import Unsplash, { toJson } from 'unsplash-js';

const unsplash = new Unsplash({
accessKey: config.get('ACCESS_KEY'),
secret: config.get('SECRET'),
callbackUrl: config.get('CALLBACK_URL')
accessKey: config.get('ACCESS_KEY')
});

let authenticationUrl = unsplash.auth.getAuthenticationUrl([
"public",
"read_user",
"write_user",
"read_photos",
"write_photos",
"write_likes",
"read_collections",
"write_collections"
]);

console.log(userAuthentication(code));
currentUser();
users();
photos();
collections();
stats();

function userAuthentication(code) {
return unsplash.auth.userAuthentication(code)
.then(toJson)
.then(json => json.access_token);
}

function currentUser() {
console.log("\nCurrent User");

unsplash.currentUser.profile()
.then(toJson)
.then(json => {
console.log('profile', json);
});

unsplash.currentUser.updateProfile({ location: "¯\_(ツ)_/¯" })
.then(toJson)
.then(json => {
console.log('updateProfile', json);
});
}

function users() {
console.log("\nUsers")

Expand Down Expand Up @@ -89,18 +52,6 @@ function photos() {
.then(json => {
console.log(json.links.html);
});

unsplash.photos.likePhoto("kZ8dyUT0h30")
.then(toJson)
.then(json => {
console.log(json);
});

unsplash.photos.unlikePhoto("kZ8dyUT0h30")
.then(toJson)
.then(json => {
console.log(json);
});
}

function collections() {
Expand All @@ -123,36 +74,6 @@ function collections() {
.then(json => {
console.log(json);
});

unsplash.collections.createCollection("Birds", "Wild birds from 'round the world", true)
.then(toJson)
.then(json => {
console.log(json);
});

unsplash.collections.updateCollection(152645, "Wild", "Wild")
.then(toJson)
.then(json => {
console.log(json);
});

unsplash.collections.deleteCollection(152645)
.then(toJson)
.then(json => {
console.log(json);
});

unsplash.collections.addPhotoToCollection(151165, '-yPg8cusGD8')
.then(toJson)
.then(json => {
console.log(json);
});

unsplash.collections.removePhotoFromCollection(151165, '-yPg8cusGD8')
.then(toJson)
.then(json => {
console.log(json);
});
}

function stats() {
Expand Down

0 comments on commit 319fa55

Please sign in to comment.