Skip to content

Commit f72666e

Browse files
committed
fix: apigw api exist bug
1 parent a618478 commit f72666e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/baas/apigw/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ class Apigw {
146146
console.debug(`Updating api with api id ${endpoint.apiId}.`)
147147
await this.request({
148148
Action: 'ModifyApi',
149-
apiId: endpoint.appId,
149+
apiId: endpoint.apiId,
150150
...apiInputs
151151
})
152152
output.apiId = endpoint.apiId
@@ -331,16 +331,20 @@ class Apigw {
331331
const { endpoints } = inputs
332332
for (let i = 0, len = endpoints.length; i < len; i++) {
333333
const endpoint = endpoints[i]
334-
const curApi = await this.createOrUpdateApi({
335-
serviceId,
336-
endpoint
337-
})
338334
// if exist in state list, set created to be true
339-
const exists = stateApiList.filter(
335+
const [exist] = stateApiList.filter(
340336
(item) =>
341337
item.method.toLowerCase() === endpoint.method.toLowerCase() && item.path === endpoint.path
342338
)
343-
if (exists && exists.length > 0) {
339+
340+
if (exist) {
341+
endpoint.apiId = exist.apiId
342+
}
343+
const curApi = await this.createOrUpdateApi({
344+
serviceId,
345+
endpoint
346+
})
347+
if (exist) {
344348
curApi.created = true
345349
}
346350

0 commit comments

Comments
 (0)