[英]Google Books API Rate Limit Exceeded
With this demo I get rate limit exceeded from the Google Books API:通过此演示,我从 Google Books API 中获得了超出速率限制:
https://angular-temp-slice-demo.stackblitz.io/books https://angular-temp-slice-demo.stackblitz.io/books
To see it open the developer console in chrome and then do some searches.要查看它,请在 chrome 中打开开发者控制台,然后进行一些搜索。 The rate limit errors will show in the console.
速率限制错误将显示在控制台中。
[],"lazyUpdate":null},"status":403,"statusText":"OK","url":"https://www.googleapis.com/books/v1/volumes?q=test","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://www.googleapis.com/books/v1/volumes?q=test: 403 OK","error":{"error":{"errors":[{"domain":"usageLimits","reason":"userRateLimitExceededUnreg","message":"User Rate Limit Exceeded. Please sign up","extendedHelp":"https://code.google.com/apis/console"}],"code":403,"message":"User Rate Limit Exceeded. Please sign up"}}}
This is the search code (And a link to the stackblitz book.service) :这是搜索代码(以及 stackblitz book.service 的链接) :
onSearch(query: string) {
this.bookStore.query = query;
this.query$.pipe(
filter(Boolean),
debounceTime(500),
distinctUntilChanged(),
tap(async (query: string) => {
const bo: Observable<Book[]> = this.searchAPI(query);
const books: Book[] = await bo.toPromise();
this.bookStore.reset();
this.bookStore.postA(books);
})
)
.subscribe();
However this Akita demo does not get this:然而这个秋田演示没有得到这个:
https://akita-books-store.stackblitz.io/#/books/find https://akita-books-store.stackblitz.io/#/books/find
Anyone know what's causing the rate limit exceeded error?任何人都知道是什么导致了超出速率限制的错误? I have set debounce time to 500 milliseconds.
我已将去抖动时间设置为 500 毫秒。
This fixes it:这修复了它:
constructor(private http: HttpClient) {
this.bookStore.observeQuery().pipe(filter(Boolean),
debounceTime(200),
distinctUntilChanged(),
tap(async (query: string) => {
const bo: Observable<Book[]> = this.searchAPI(query);
const books: Book[] = await bo.toPromise();
this.bookStore.reset();
this.bookStore.postA(books);
})
)
.subscribe();
}
Before I was doing the above code block inside of onSearch
and it causes to a subscription to be created each time the onSearch
triggered.在我在
onSearch
内部执行上述代码块之前,每次触发onSearch
时都会创建订阅。 Now the only thing in onSearch
is this:现在
onSearch
中唯一的内容是:
onSearch(query: string) {
this.bookStore.query = query;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.