1
我必须使用sagas和generator函数调用API。这里是我的代码:生成器函数不显示我的数据,如何访问它?
export function* fetchCreate(data) {
try {
const options = jsonBodyOptions(data);
const tagResponse = yield call(
fetchJson,
apiPath + '/fetch',
tagOptions
);
return tagResponse;
} catch (err) {
console.log(err);
}
}
export function* callFetch(data) {
const response = fetchCreate(data);
}
如果我打印fetchCreate()
,我看到发生器功能打印。
我想从同一文件中的另一个函数调用该生成器函数。我主要想要从该函数的响应,但基本上它返回一个生成器。我如何从中获取响应?