Hi, The version of redux-saga is: "^0.16.0" Here the mock API: And here my saga: Can someone tell my what i'm not doing correctly ? thanks alot guys !
It's my first issue ans I didn'T find a way to label it, sorry. I'm trying to call a mock API and i got this error:
error TS2345: Argument of type 'Promise
Type 'Promise getAllMembersAsync() : Promise<Program[]> {
const promise : Promise<Array<Program>> = new Promise((resolve, reject) => {
var members : Array<Program>;
members = ProgramsData.map((currentProgram) => {
var program : Program = new Program();
program.code = currentProgram.code;
program.nom = currentProgram.nom;
program.cours = currentProgram.cours;
return program;
});
resolve(members);
// });
});
return promise;
}
import {call, put, takeLatest} from 'redux-saga/effects';
import { receivedPrograms, FetchPrograms, FETCH_PROGRAMS } from '../actions/programActions';
import { Program } from '../model/program';
import programAPI from '../api/programAPI';
function* fetchPrograms(action: FetchPrograms) {
let programs: Array<Program>;
programs = yield call(programAPI.getAllMembersAsync());
yield put(receivedPrograms(programs));
}
I have nearly zero experience with TS, but maybe you could try this:
programs = yield call(programAPI.getAllMembersAsync);
call is responsible for actually executing ur function, so invoking it here is probably not what u were looking for.
Thanks a lot @Andarist, my nearly zero experience with TS in nearer of zero than yours.
thanks again !
I guess this can be closed then. Glad it helped :)
Most helpful comment
I have nearly zero experience with TS, but maybe you could try this:
callis responsible for actually executing ur function, so invoking it here is probably not what u were looking for.