我正在使用 PokeAPI,浏览器端使用 PokeAPI js 包装器 CDN。
HTML:
<script src="https://unpkg.com/pokeapi-js-wrapper/dist/index.js"></script>
<script src="/scripts/app.js" defer></script>
我从包装库的文档中复制了代码: https://github.com/PokeAPI/pokeapi-js-wrapper#install
这是我的 app.js 中的内容:
const P = new Pokedex.Pokedex()
// with await, be sure to be in an async function (and in a try/catch)
(async() => {
const golduck = await P.getPokemonByName("golduck");
console.log(golduck);
})();
它抛出这个错误:
app.js:3 Uncaught TypeError: (intermediate value) is not a function
at app.js:3
(anonymous) @ app.js:3