Projekt

Obecné

Profil

Stáhnout (668 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1 8c57f958 Vaclav Honzik
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 dd270a41 Vaclav Honzik
            console.log(err)
17 8c57f958 Vaclav Honzik
            return Promise.reject('Error, server is currently unavailable')
18
        }
19
    }
20
)