Skip to content

Commit f4291a3

Browse files
Updated demo app to take out unsplash
1 parent cefd522 commit f4291a3

File tree

12 files changed

+3
-9
lines changed

12 files changed

+3
-9
lines changed
File renamed without changes.

apps/random-unsplash-demo/app.js renamed to apps/random-cats-demo/app.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ const express = require('express');
22
const app = express();
33
const port = 3000;
44

5-
const unsplashKey = process.env.UNSPLASH_KEY;
6-
75
// Set EJS as the view engine
86
app.set('view engine', 'ejs');
97

@@ -34,12 +32,8 @@ app.get('/', async (req, res) => {
3432
// Dynamically import the 'node-fetch' module
3533
const fetch = (await import('node-fetch')).default;
3634

37-
// Fetch a random image from Unsplash based on search criteria
38-
const response = await fetch('https://api.unsplash.com/photos/random?query=cat&content_filter=high&orientation=landscape', {
39-
headers: {
40-
'Authorization': `Client-ID ${unsplashKey}`
41-
}
42-
});
35+
// Fetch a random image from https://loremflickr.com
36+
const response = await fetch('https://loremflickr.com/640/480');
4337

4438
const data = await response.json();
4539
const imageUrl = data.urls.regular;
@@ -53,7 +47,7 @@ app.get('/', async (req, res) => {
5347
});
5448
} catch (error) {
5549
console.error(error);
56-
res.status(500).send('Error fetching image from Unsplash');
50+
res.status(500).send('Error fetching image from loremflicker.com');
5751
}
5852
});
5953

File renamed without changes.

0 commit comments

Comments
 (0)