berkerol / photo-of-the-day

Downloads Bing, NASA, National Geographic, Unsplash Photo of the Day and sets it as wallpaper
https://berkerol.github.io/photo-of-the-day/
GNU General Public License v3.0
11 stars 2 forks source link

UnhandledPromiseRejectionWarning: Error: Error: Request failed with status code 403 #8

Closed YIN-Renlong closed 2 years ago

YIN-Renlong commented 3 years ago

Hi, First of all, thank you for your project. However, when I tried to download NG photos with a command line potd -N -d, the following error occurred:

(node:27436) UnhandledPromiseRejectionWarning: Error: Error: Request failed with status code 403
    at axios.then.catch.err (/usr/local/lib/node_modules/photo-of-the-day/app.js:152:10)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:27436) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:27436) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Any possible solution? Thanks

berkerol commented 2 years ago

You need to add the date after -d. You can find examples about it in the readme.

YIN-Renlong commented 2 years ago

Hi, I would like to let you know that even if the format is used correctly, it will still show the same error.

The command I used is potd -N -d 2020-09-04.

In the history file used last year, I saw that NG has changed the URL of the image file, and the link used before seems to be no longer valid more, such as:

https://www.nationalgeographic.com/content/dam/photography/photos/000/936/93627.jpg https://www.nationalgeographic.com/content/dam/photography/photos/000/936/93626.jpg https://www.nationalgeographic.com/content/dam/photography/photos/000/936/93625.jpg https://www.nationalgeographic.com/content/dam/photography/photos/000/936/93621.jpg ...

Any idea to fix it? Thanks