use axiosInstance inside of LinkedItems component
				
					
				
			This commit is contained in:
		| @@ -1,7 +1,7 @@ | ||||
| import {useState, useEffect} from 'react' | ||||
| import {Stack, Typography, Button, FormControl, Grid, Box, Accordion, AccordionSummary, AccordionDetails, useTheme, TextField, Autocomplete} from '@mui/material' | ||||
| import ExpandMoreIcon from '@mui/icons-material/ExpandMore' | ||||
| import axios from 'axios' | ||||
| import {axiosInstance} from '../providers/data' | ||||
| import {BACKEND_URL} from '../lib/constants' | ||||
| import {Link} from 'react-router' | ||||
|  | ||||
| @@ -38,7 +38,7 @@ export const LinkedItems = <T extends {id: number; [key: string]: any}>({parentI | ||||
|  | ||||
|   useEffect(() => { | ||||
|     if (parentId) { | ||||
|       axios | ||||
|       axiosInstance | ||||
|         .get(`${BACKEND_URL}/${parentResource}/${parentId}/${childResource}`) | ||||
|         .then((response) => { | ||||
|           setLinkedItems(response?.data || []) | ||||
| @@ -51,7 +51,7 @@ export const LinkedItems = <T extends {id: number; [key: string]: any}>({parentI | ||||
|  | ||||
|   useEffect(() => { | ||||
|     if (type === 'edit') { | ||||
|       axios | ||||
|       axiosInstance | ||||
|         .get(`${BACKEND_URL}/${childResource}/`) | ||||
|         .then((response) => { | ||||
|           setItems(response?.data || []) | ||||
| @@ -91,10 +91,10 @@ export const LinkedItems = <T extends {id: number; [key: string]: any}>({parentI | ||||
|               [`${childResource}_id`]: selectedItemId, | ||||
|             } | ||||
|  | ||||
|       axios | ||||
|       axiosInstance | ||||
|         .post(`${BACKEND_URL}/${parentResource}/${parentId}/${childResource}`, requestData) | ||||
|         .then(() => { | ||||
|           axios.get(`${BACKEND_URL}/${parentResource}/${parentId}/${childResource}`).then((response) => { | ||||
|           axiosInstance.get(`${BACKEND_URL}/${parentResource}/${parentId}/${childResource}`).then((response) => { | ||||
|             setLinkedItems(response?.data || []) | ||||
|             setSelectedItemId(null) | ||||
|             if (childResource === 'article') { | ||||
| @@ -109,7 +109,7 @@ export const LinkedItems = <T extends {id: number; [key: string]: any}>({parentI | ||||
|   } | ||||
|  | ||||
|   const deleteItem = (itemId: number) => { | ||||
|     axios | ||||
|     axiosInstance | ||||
|       .delete(`${BACKEND_URL}/${parentResource}/${parentId}/${childResource}`, { | ||||
|         data: {[`${childResource}_id`]: itemId}, | ||||
|       }) | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import {BACKEND_URL} from '../lib/constants' | ||||
| import {TOKEN_KEY} from '../authProvider' | ||||
| import Cookies from 'js-cookie' | ||||
|  | ||||
| const axiosInstance = axios.create() | ||||
| export const axiosInstance = axios.create() | ||||
|  | ||||
| axiosInstance.interceptors.request.use((config) => { | ||||
|   // Добавляем токен авторизации | ||||
|   | ||||
		Reference in New Issue
	
	Block a user