【发布时间】:2019-08-28 07:51:45
【问题描述】:
代码从服务器获取数据数组
fetch('/api/collections/get/posts?token=xxtokenxx', {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
filter: {published:true},
})
})
.then(res=>res.json())
.then(res => console.log(res));
我需要使用 Graphql 存储这些数据并获取特定数据,但我不知道如何通过 Gatsby js 实现这一点(如果可能的话)。
【问题讨论】:
-
尝试添加更多屏幕截图。我没有看到您正在使用 GraphQL 端点。当你记录数据时你有什么?显示您在服务器上的内容。基本上,我建议你先玩 GraphQL Playground。
-
您的意思是获取这些数据,然后将它们导入到 gatsby 中,以便在开发过程中使用 graphql 查询它们吗?
标签: reactjs rest graphql gatsby