GraphQL学习、踩坑记录(三)
如果您发现本文排版有问题,可以先点击下面的链接切换至老版进行查看!!!
GraphQL学习、踩坑记录(三)


// query/index.js
module.exports = `
query($id: ID) {
posts(post_type: "post"){
ID
}
post(id: $id){
ID,
post_content,
}
}
`;
import axios from 'axios';
import query from '../query/index';
// 这样调用
const res = await axios.post('http://localhost:5050/graphql', {
query: sql,
variables: {
id: 2668
}
});
const { data: { data } } = res;
console.log('data ', data);
发起的请求也是和与GraphiQL一样

- 分类:
- Web前端
更新时间:
上一篇:下一篇: