https://pulumi.com logo
#typescript
Title
# typescript
w

wet-ambulance-3300

02/23/2021, 3:35 PM
Is something like this possible? (Essentially destructuring a promise)
Copy code
const [projectId, projectNumber] = gcp.organizations.getProject({}).then(prj => [prj.id, prj.number])
c

colossal-australia-65039

02/23/2021, 8:20 PM
wouldn't
Copy code
const [projectId, projectNumber] = await gcp.organizations.getProject({})
work? (assuming
getProject
does return a
Promise<[string, number]>
or similar)
w

wet-ambulance-3300

03/01/2021, 11:51 AM
Hi @colossal-australia-65039, thanks for the response. Doesn't seem so.
Type 'GetProjectResult' must have a '[Symbol.iterator]()' method that returns an iterator.
https://www.pulumi.com/docs/reference/pkg/gcp/organizations/getproject/#result
c

colossal-australia-65039

03/01/2021, 5:03 PM
ah so getProject returns a future object. so you'll have to use different syntax for destructuring:
Copy code
const {id, number} = await gcp.organizations.getProject({})
or if you want to rename the props and destructure at the same time
Copy code
const {id: projectId, number: projectNumber} = await gcp.organizations.getProject({})