# How to use a token with axios?

**URL:** <https://community.auth0.com/t/how-to-use-a-token-with-axios/63171>\
**Category:** Get Help\
**Created:** [May 21, 2021, 3:27pm UTC](https://community.auth0.com/t/how-to-use-a-token-with-axios/63171 "2021-05-21T15:27:05Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [May 25, 2021, 7:02pm UTC](https://community.auth0.com/t/how-to-use-a-token-with-axios/63171/15 "2021-05-25T19:02:20Z")

</div>

Thanks for confirming. I’ve played around with this a bit and I think because `useAxios` is a hook, it would be challenging to use this with `getAccessTokenSilently` since you can’t use a hook within `useEffect`. You may need to use Axios alone within `useEffect` so that you can get the accessToken before making the request:

```auto
import React, { useEffect, useState } from "react";
import { Container, Row, Col } from "reactstrap";

import Highlight from "../components/Highlight";
import { useAuth0, withAuthenticationRequired } from "@auth0/auth0-react";
import Axios from "axios";

export const ProfileComponent = () => {
  const { user, getAccessTokenSilently } = useAuth0();
  const [groups, setGroupsData] = useState(null);

  useEffect(() => {
    const getUserMetadata = async () => {
      try {
        const accessToken = await getAccessTokenSilently();
        const groupData = await Axios.get(`https://jsonplaceholder.typicode.com/users`, {
          headers: {
            Authorization: `bearer ${accessToken}`
          }
        });
        setGroupsData(groupData);
      } catch (e) {
        console.log(e.message);
      }
    };
  
    getUserMetadata();
  }, []);

  return (
    <Container className="mb-5">
      <Row>
        <Highlight>{JSON.stringify(groups, null, 2)}</Highlight>
      </Row>
      <Row>
        <Highlight>{JSON.stringify(user, null, 2)}</Highlight>
      </Row>
    </Container>
  );
};

export default withAuthenticationRequired(ProfileComponent);

```

---

_[View the full topic](https://community.auth0.com/t/how-to-use-a-token-with-axios/63171)._
