【发布时间】:2020-04-08 14:00:26
【问题描述】:
我用 next.js 创建了一个页面,如下所示。
早期使用getInitialProps()set 属性。它也使用异步调用。然后我想知道在 next.js 中使用 redux saga 真的很有用。
sampleFetchWrapper() 实现如下。
import fetch from 'isomorphic-unfetch'
export async function sampleFetchWrapper(
input: RequestInfo,
init?: RequestInit
) {
try {
const data = await fetch(input, init).then(res => res.json())
return data
} catch (err) {
throw new Error(err.message)
}
}
这里是其他人的the post using redux saga with next.js。但我想知道这是不是正确的方法。你能推荐正确的想法吗?
【问题讨论】:
标签: javascript reactjs redux next.js saga