1

so I'm doing this assignment and can't seem to understand how to make the request that I'm being asked to do, the information given is the following (going to be editing the names):

api url: https://this.api.com/entity

api apikey: somePa$$word

and 2 endpoints to get information based on an user info:

/category/userID=11111111

/category/userPassport=20111111113

An example of usage was given: screenshot of example

I'm not really clear on how to write this and so far every post I found doesn't work.

What I have so far:

const [apiData, setApiData] = useState(null);
  useEffect(() => {
    axios
      .get(
         //testing attaching the endpoint as the example shows?
        'https://this.api.com/entity/category/userID=11111111', 
        {
          headers: {
            Authorization: `Apikey somePa$$word`,
          },
        }
      )
      .then((res) => {
        setApiData(res.data);
        console.log('axios: ' + res.data);
      });
      .catch((error) => {
        console.log('axios: ' + error);
      });
  }, []);

I get these errors in the console: console errors

First time I ask a question here and I hope the info I provided is enough, if anything else is needed pls let me know.

Thanks you

Damian
  • 15
  • 1

1 Answers1

0

try this

axios
      .get(
         //testing attaching the endpoint as the example shows?
        'https://this.api.com/entity/category/userID=11111111', 
        {
          headers: {
            Authorization: `Apikey somePa$$word`,
            'Access-Control-Allow-Origin': '*',
          },
        }
      )
Dean Van Greunen
  • 5,060
  • 2
  • 14
  • 28