简体   繁体   English

如何在themoviedb API中获得所有评论?

[英]How to get all reviews in themoviedb api?

I am creating a rest api , I would like to retrieve or get all reviews/comments which are in a database. 我正在创建rest api,我想检索或获取数据库中的所有评论/评论。

This is what I have done : 这是我所做的:

app.get('/review', (req, res) =>{
        request('https://api.themoviedb.org/3/review?api_key=4d9c9de3bdf0d3b6837c49c086e3b190', function (error, response, body) {
            console.log('error:', error); // Print the error if one occurred and handle it
            console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
            res.send(body)
          });
    });

I am getting this error: {"status_code":34,"status_message":"The resource you requested could not be found."} 我收到此错误: {"status_code":34,"status_message":"The resource you requested could not be found."}

what am I doing wrong here? 我在这里做错了什么? help 救命

Note: other methods works perfectly 注意:其他方法效果很好

This isn't a JS error or anything. 这不是JS错误或其他任何错误。 If you look at the API Documentation , status_code: 34 means you're accessing an endpoint that doesn't exist . 如果您查看API文档status_code: 34表示您正在访问不存在的端点。

Diving into the docs a bit further, you can't get ALL the reviews in the database. 再深入研究一下文档,您将无法获得数据库中的所有评论。 All you can do is get the reviews on a per movie basis. 您所能做的就是获得每部电影的评论。 Try this URL: 试试这个网址:

https://api.themoviedb.org/3/movie/401478/reviews?api_key=4d9c9de3bdf0d3b6837c49c086e3b190

Here's the documentation on the /movie/<movie_id>/reviews endpoint: https://developers.themoviedb.org/3/movies/get-movie-reviews 这是/movie/<movie_id>/reviews端点上的文档: https : //developers.themoviedb.org/3/movies/get-movie-reviews

There is also the /review/<review_id> end point, but it appears that gets a single review by id which probably isn't what you're looking for: https://developers.themoviedb.org/3/reviews/get-review-details 还有/review/<review_id>端点,但是似乎可以通过id获得单个评论,这可能不是您想要的: https : //developers.themoviedb.org/3/reviews/get -审查-细节

It has nothing to do with nodeJS .As stated by @VicJordan, the problem is only with the url you are trying to search, it's simply not a valid API request. 它与nodeJS 。正如@VicJordan所说,问题仅在于您要搜索的url ,这根本不是有效的API请求。 Try to go thru API documentation to find out how to use them. 尝试浏览API文档以了解如何使用它们。 An example of a valid URL would be: 有效URL的示例为:

https://api.themoviedb.org/3/discover/movie?api_key=4d9c9de3bdf0d3b6837c49c086e3b190

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM