Skip to content

Conversation

@KrSkander
Copy link

Redux Store setup including :

  • Profile Details Fetching
  • Repositories List Fetching

🦇

Comment on lines 10 to 19
//const [profile, setProfile] = useState({});

useEffect(() => {
axios.get(`https://api.github.com/user`).then((response) => {
setProfile(response.data);
});
});
const dispatch = useDispatch()
const userData = useSelector((state) => state.profile.userData)

useEffect(() => {
dispatch(fetchProfileData())
// axios.get(`https://api.github.com/user`).then((response) => {
// setProfile(response.data);
// });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated code would rather be deleted :trash:

Comment on lines 25 to 38
// const fetchRepos = () => {
// setRepos("loading");
// axios
// .get("https://api.github.com/user/repos", {
// params: filters,
// })
// .then((response) => {
// setRepos(response.data);
// })
// .catch((error) => {
// console.log(error);
// setRepos([]);
// });
// };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this. Leaving commented outdated code will affect code readability

const fetchProfileData = createAsyncThunk(
'profile/fetchProfileData',
async () => {
const res = await axios.get('https://api.github.com/user')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we abstract the baseUrl https://api.github.com and make it an environment variable in .env

const fetchRepos = createAsyncThunk(
'repos/fetchRepos',
async () => {
const res = await axios.get('https://api.github.com/user/repos')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we abstract the baseUrl and make it an environment variable we will directly use it here.
If for some reason, we or the thrid party (github) are changing the url, we will change it once

@KrSkander
Copy link
Author

@Ikdemm I'll make sure to apply the fixes and commit right away !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants