我是本机新手,正在使用axios和fetch进行一些测试 请查看此网址(可在Google上公开获得)
https://www.dolarsi.com/api/api.php?type=valoresprincipales
如果您将其加载到浏览器中,则会显示json响应
我无法使其与axios或fetch一起使用。
const obtenerCotizacionDolar = async () => {
try {
console.log('Entró a cotizar el dolar');
const urlAPI = 'https://www.dolarsi.com.ar/api/api.php?type=valoresprincipales';
//const urlAPI = 'http://api.openweathermap.org/data/2.5/weather?q=San%20Juan,AR&appid=dcebd1a---------80472ed405';
try {
await axios.get(urlAPI)
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error);
});
} catch (error) {
console.log(error);
}
//console.log('Resultado API: ', resultadoAPI);
// 4. you change the state of this component,
// React will run the next render-cycle of this component
guardarResultado(resultadoAPI);
guardarPuedeConsultar(false);
} catch (error) {
// mostrarAlerta();
}
}
obtenerCotizacionDolar()
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
我已经尝试过使用openweathermap API url,并且一切正常
有谁知道它是否与该特定域,cors,ssl cert等相关?
谢谢