Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPError: Response code 404 (Not Found) for getAnimeData() #6

Closed
johnRambo2k14 opened this issue Sep 30, 2017 · 2 comments
Closed

Comments

@johnRambo2k14
Copy link

johnRambo2k14 commented Sep 30, 2017

Hi, I really appreciate the work you do and it has helped me out in some of my personal projects! Hoowever, just last night getAnimeData() stopped working.

My Code:

this.horribleSubs.getAllAnime().then((HsRes) => {
               return HsRes;
            }).then((data) => {
                return this.horribleSubs.getAnimeData(data);
            }).then((data) => {
                res.send(data);
            })
            .catch(err => console.error(err));

The Error thrown:

{ HTTPError: Response code 404 (Not Found)
    at StdError (C:\Users\LOLCAT\Documents\animstream\animstream-backend\node_modules\got\index.js:410:3)
    at C:\Users\LOLCAT\Documents\animstream\animstream-backend\node_modules\got\index.js:454:3
    at stream.catch.then.e (C:\Users\LOLCAT\Documents\animstream\animstream-backend\node_modules\got\index.js:182:13)
    at process._tickCallback (internal/process/next_tick.js:109:7)
  name: 'HTTPError',
  host: 'horriblesubs.info',
  hostname: 'horriblesubs.info',
  method: 'GET',
  path: '/undefined?',
  protocol: 'https:',
  url: 'https://horriblesubs.info/undefined',
  statusCode: 404,
  statusMessage: 'Not Found',
  headers:
   { date: 'Sat, 30 Sep 2017 11:43:40 GMT',
     'content-type': 'text/html; charset=UTF-8',
     'transfer-encoding': 'chunked',
     connection: 'close',
     'set-cookie': [ '__cfduid=d65ea6297084293854bcaf026ece578e71506771820; expires=Sun, 30-Sep-18 11:43:40 GMT; path=/; domain=.horriblesubs.info; HttpOnly' ]
,
     vary: 'Cookie',
     expires: 'Wed, 11 Jan 1984 05:00:00 GMT',
     'cache-control': 'no-cache, must-revalidate, max-age=0',
     link: '<http://horriblesubs.info/wp-json/>; rel="https://api.w.org/"',
     server: 'cloudflare-nginx',
     'cf-ray': '3a66ed037dfe6b91-LHR',
     'content-encoding': 'gzip' } }

I would assume changed their DOM in some way which could be the reason throwing this error?

@ChrisAlderson
Copy link
Owner

This is because the getAllAnime method returns an array with objects in them. The getAnimeData takes an object out the array of objects as a parameter. You can see it in the example included in the readme file of this repo.

// Get all available shows on horriblesubs.
horriblesubs.getAllAnime().then(res => {
  const [ data ] = res // same as: const data = res[0]
  console.log(data)

  // Get data including episodes from horriblesubs.
  return horriblesubs.getAnimeData(data)
}).then(res => console.log(res))
  .catch(err => console.error(err))

@johnRambo2k14
Copy link
Author

Oh man thank you, clearly I haven't had my morning coffee yet 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants