Answers for "How to send headers using swr"

0

How to send headers using swr

const fetcher = (url) =>
    axios
      .get(url, { headers: { Authorization: "Bearer " + auth.token } })
      .then((res) => res.data);
  const { data, error } = useSWR(
    `http://localhost:8000/api/v1/users/get-avatar`,
    fetcher
  );
  if (error) console.log(error);
  if (data) console.log(data);
Posted by: Guest on April-02-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language