Is something like this possible? (Essentially dest...
# typescript
w
Is something like this possible? (Essentially destructuring a promise)
Copy code
const [projectId, projectNumber] = gcp.organizations.getProject({}).then(prj => [prj.id, prj.number])
c
wouldn't
Copy code
const [projectId, projectNumber] = await gcp.organizations.getProject({})
work? (assuming
getProject
does return a
Promise<[string, number]>
or similar)
w
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
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({})