I want to show the variable from API in variax
I use axios to access api for django rest-framework and then
put this in variax
But it still shows 2
I am famillier with Django
but not django
Please give me some help.
import React, { Fragment, useEffect } from 'react';
import axios from 'axios';
const App = () => {
let variax = 1;
variax = 2;
useEffect(() => {
axios.get('http://localhost:8000/api/results/')
.then(res=>{
console.log(res.data);
variax = res.data;
})
.catch(err=>{console.log(err);});
}, []);
return(
<Fragment>
{variax}
</Fragment>
);
}
export default App;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…