Bing Search API有时会返回:myscript.js:109 Uncaught TypeError:无法读取属性' trim'未定义的

时间:2018-04-04 14:28:17

标签: javascript bing bing-api

我有一个使用Bing Search API返回搜索结果的演示应用。

https://codepen.io/Teeke/pen/JLadEz

成功的搜索查询返回:

XHR finished loading: GET "https://api.cognitive.microsoft.com/bing/v7.0/search?q=learn%20javascript&mkt=en-GB&SafeSearch=strict&count=25&offset=0&textDecorations=true&textFormat=HTML".

有时,搜索查询会打开一个新的浏览器窗口,并返回“未定义”。控制台返回:

myscript.js:109 Uncaught TypeError: Cannot read property 'trim' of undefined
    at showDiv (myscript.js:109)
    at bingWebSearch (myscript.js:322)
    at HTMLFormElement.onsubmit ((index):26)
showDiv @   myscript.js:109
bingWebSearch   @   myscript.js:322
onsubmit    @   (index):26

为什么搜索有时不起作用?是因为试用API的速率有限吗?

0 个答案:

没有答案