Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2137 Rev 2194
Línea 34... Línea 34...
34
  payload: page
34
  payload: page
35
})
35
})
Línea 36... Línea 36...
36
 
36
 
37
export const fetchFeeds = (url, page) => {
37
export const fetchFeeds = (url, page) => {
38
  return (dispatch) => {
38
  return (dispatch) => {
39
    if (!url || url.includes('undefined')) {
-
 
40
      return
-
 
Línea 41... Línea 39...
41
    }
39
    if (!url || url.includes('undefined')) return
Línea 42... Línea -...
42
 
-
 
43
    dispatch(loadFeeds())
-
 
44
 
40
 
45
    axios
41
    dispatch(loadFeeds())
46
      .get(url + '?page=' + page)
42
 
47
      .then(({ data: response }) => {
43
    axios.get(url + '?page=' + page).then(({ data: response }) => {
48
        const { data, success } = response
44
      const { data, success } = response
-
 
45
 
49
 
46
      if (!success) {
-
 
47
        throw new Error(
-
 
48
          'Error al obtener las publicaciones, por favor intente más tarde'
50
        if (!success) {
49
        )
51
          return
50
      }
52
        }
51
 
53
        const feeds = data.current.items
52
      const feeds = data.current.items
54
        const currentPage = data.current.page
53
      const currentPage = data.current.page
55
        const pages = data.total.pages
-
 
56
 
-
 
57
        dispatch(loadFeedsSuccess(feeds, currentPage, pages))
-
 
58
      })
-
 
59
      .catch((err) => {
54
      const pages = data.total.pages
60
        console.log(err)
55
 
61
        throw new Error(err)
56
      dispatch(loadFeedsSuccess(feeds, currentPage, pages))
Línea 62... Línea 57...
62
      })
57
    })
63
  }
58
  }