Answer the question
In order to leave comments, you need to log in
Why does it give me that the axios module is not connected?
import React, { useState, useEffect } from 'react';
import { Text, View } from 'react-native';
import axios from 'axios';
export default function MyComponent() {
const [error, setError] = useState(null);
const [isLoaded, setIsLoaded] = useState(true);
const [obj, setObj] = useState({});
const apikey = '8cf291153ac6194489c23f45854a241e';
const fu = async () => {
setIsLoaded(true)
const res = await axios.get(` https://samples.openweathermap.org/data/2.5/weathe...
setObj(res.data)
console.log( res.data)
setIsLoaded(false)
}
useEffect(() => {
fu()
}, []);
if (error) {
return
Error: {error.message}
;
}
if (isLoaded) {
return
Loading...
;
}
return (
city {obj.name}
temperature {obj.main.temp}
pressure {obj.main.pressure}
);
}
Answer the question
In order to leave comments, you need to log in
probably because the documentation says
If it doesn't help, then read https://github.com/axios/axios and show your package.json const axios = require('axios');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question