Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 1718 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1718 Rev 2076
Línea 1... Línea 1...
1
import { axios } from '@app/utils'
1
import { axios } from '@app/utils'
Línea 2... Línea 2...
2
 
2
 
3
export const getConversations = async (url) => {
3
export const getConversations = async (url) => {
4
  return axios.get(url).then(({ data: response }) => {
4
  return axios.get(url).then((response) => {
Línea 5... Línea 5...
5
    const { data, success } = response
5
    const { data, success } = response.data
6
 
6
 
7
    if (!success) {
7
    if (!success) {
Línea 8... Línea 8...
8
      throw new Error('Ha ocurrido un error al obtener las conversaciones')
8
      throw new Error('Ha ocurrido un error al obtener las conversaciones')
9
    }
9
    }
10
 
10
 
-
 
11
    return data
-
 
12
  })
-
 
13
}
-
 
14
 
-
 
15
export const getCurrentContacts = async (search = '') => {
-
 
16
  return axios
-
 
17
    .get(`/chat/users?search=${search.toLowerCase()}`)
-
 
18
    .then((response) => {
-
 
19
      const { data, success } = response.data
-
 
20
 
-
 
21
      if (!success) {
-
 
22
        throw new Error(
-
 
23
          'Ha ocurrido un error al obtener la obtener los contactos, por favor intente más tarde.'
-
 
24
        )
-
 
25
      }
-
 
26
 
-
 
27
      return data
-
 
28
    })
-
 
29
}
-
 
30
 
-
 
31
export const startConversation = async (link_open_or_create) => {
-
 
32
  return axios.post(link_open_or_create).then((response) => {
-
 
33
    const { success, data } = response.data
-
 
34
 
-
 
35
    if (!success) {
-
 
36
      throw new Error('Ha ocurrido un error al iniciar la conversación')
-
 
37
    }
-
 
38