0

how can i send my token to getDeneme function

i can take the token but i can't send to getDeneme

i take that eror : GET http://127.0.0.1:8000/account/auth/user/ 401 (Unauthorized)

This is my Code

import React from 'react'
import axios from 'axios';
import { useEffect } from 'react';
import { useState } from 'react';
import { Formik, Field, Form } from 'formik';


const Login = () => {
  const [auth, setAuth] = useState()

  const urlLogin = 'http://127.0.0.1:8000/account/auth/login/'
  const urlDeneme = 'http://127.0.0.1:8000/account/auth/user/'



  const addLogin = async (logins) => {
    try {
      const response = await axios.post(urlLogin, logins);
      console.log(JSON.stringify(response?.data));
      //console.log(JSON.stringify(response));
      const accessToken = response?.data?.key;
      const roles = response?.data?.roles;
      setAuth(accessToken);
      console.log(auth);
    } catch (err) {
      console.log(err);
    }
  }
  const getDeneme = async (auth) => {
    try {
      const { data } = await axios.get(urlDeneme)
        } catch (error) {
          console.log(error);
        }
    };

0 Answers0