从我的反应应用程序运行以下代码时,我不断收到相同的错误,即网络错误,特别是 NS_BINDING_ABORTED。我很确定这与我编写的代码有关,因为我尝试过其他 API,而且我还有另一个成功调用 API 的项目。
import React, {useState} from 'react';
function App() {
const [userTickerValue, setUserTickerValue] = useState('')
const handleChangeTickerInput = (event) => {
setUserTickerValue(event.target.value)
}
const key=(taken out for privacy)
const handleFormSubmit = () => {
console.log(userTickerValue)
fetch(`https://www.alphavantage.co/query?function=TIME_SERIES_WEEKLY&symbol=${userTickerValue}&apikey=${key}`)
.then(res => res.json())
.then(data => {
console.log(data)
})
}
return (
<div className="App">
<form onSubmit={handleFormSubmit}>
<p>Ticker?<input type='text' value={userTickerValue} onChange={handleChangeTickerInput}></input></p>
</form>
</div>
);
}
export default App;