我使用Loopback4作为中央应用编程接口。我正在尝试通过Loopback中的远程方法调用第三方API的方法。我正在使用Strapi作为第三方应用程序接口,并将此信息传递给loopback4
使用Loopback,我有一个如下所示的数据源:
const strapiConfig = {
name: 'strapi',
connector: 'rest',
baseURL: appConfig.strapi.host,
crud: false,
options: {
headers: {
"accept": "application/json",
"content-type": "application/json",
"cache-control": "no-cache",
"Authorization" : `Bearer ${appConfig.strapi.token}`
}
},
operations: [
{
"template": {
"method": "GET",
"url": `${strapiUrl}/pages/{pageId}`
},
"functions": {
"getOnePage": ["pageId"]
}
},
{
"template": {
"method": "GET",
"url": `${strapiUrl}/pages`
},
"functions": {
"getPages": ""
}
},
{
"template": {
"method": "GET",
"url": `${strapiUrl}/glossary/{id}`
},
"functions": {
"getOneGlossary": ['id']
}
},
{
"template": {
"method": "GET",
"url": `${strapiUrl}/glossary`
},
"functions": {
"getGlossary": ""
}
},
{
"template": {
"method": "GET",
"url": `${strapiUrl}/faq`
},
"functions": {
"getFaqs": ""
}
},
{
"template": {
"method": "GET",
"url": `${strapiUrl}/faq/{id}`
},
"functions": {
"getOneFaq": ['id']
}
}
]
};唯一起作用的端点是页面
欢迎任何建议。谢谢!
发布于 2021-02-18 21:51:21
调用其他终结点时,您会得到哪种类型的错误/状态代码?
您是否在Strapi中设置了角色和权限?示例(取决于Strapi版本):
find
https://stackoverflow.com/questions/66261112
复制相似问题