Projekt

Obecné

Profil

Stáhnout (638 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1
import { createAsyncThunk } from '@reduxjs/toolkit'
2
import axiosInstance from '../../api/api'
3

    
4
export const sendTextForProcessing = createAsyncThunk(
5
    'trackingTool/sendTextForProcessing',
6
    async (text: string) => {
7
        try {
8
            const { data, status } = await axiosInstance.post('path', { text })
9
            if (status !== 200) {
10
                return Promise.reject(
11
                    'Error while fetching map, please try again later'
12
                )
13
            }
14
            return data
15
        } catch (err: any) {
16
            return Promise.reject('Error, server is currently unavailable')
17
        }
18
    }
19
)
(4-4/5)