Search code examples
ecmascript-6

takeLatest$1 requires a saga parameters


Problem

Hello to all, I'm tryin to use redux-saga and as the title said I have the error

takeLatest$1 requires a saga parameters

I don't know what I'm missing, and I didn't find anything related on the internet.

Code

Below you will find the file saga/index.js

import {
  GET_NEWS_REQUEST,
} from '../types';
import { takeLatest } from 'redux-saga/effects';
import { fetchRecords } from './apiCallSaga';

export default function* root() {
  yield takeLatest(GET_NEWS_REQUEST, fetchRecords,);
}

in the same folder I've the file saga/apiCallSaga.js

import { put } from 'redux-saga/effects';
import { getNewsSuccess, getNewsFailed } from '../actions';

function* fetchRecords() {

  const url = 'https://newsapi.org/v2/top-headlines?'

  try {
    const response = yield fetch(url).then(res => res.json());
    console.log(response);
    yield put(getNewsSuccess(response));
  } catch (e) {
    yield getNewsFailed();
  }
}; 

export default { fetchRecords };

Expected Behaviour

I need to make the call to a link ( the one provided isn't complete ). This error shouldn't appear.


Solution

  • Well i found the answer.

    The problem was

    export default
    

    i need only to

    export { fetchRecords };