Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
timrobinson33
9 months agoHelpful | Level 6
How do I find the return type of the response from sharingGetSharedLinkMetadata
I'm using the javascript SDK to call the `sharingGetSharedLinkMetadata` API. This API might return either a SharingFileLinkMetadata, SharingFolderLinkMetadata, or SharingSharedLinkMetadata
Normally you would use the `.tag` field to see what type has been returned but that doesn't work in this case because SharingSharedLinkMetadata uses the same tag values as the other two.
So how can I find out which of these has been returned?
3 Replies
- Greg-DB9 months ago
Dropbox Community Moderator
SharingFileLinkMetadata and SharingFolderLinkMetadata are each subtypes of SharingSharedLinkMetadata; they aren't three distinct types. So given a SharingSharedLinkMetadata, 'file' indicates a SharingFileLinkMetadata, and 'folder' indicates a SharingFolderLinkMetadata.
- timrobinson339 months agoHelpful | Level 6
Aha! Thank you for this for insight - it makes more sense now.
However the way it's been done in typescript is that the API returns FileLinkMetadataReference | FolderLinkMetadataReference | SharedLinkMetadataReference
This means as far as typescript type checking is concerned, if I test that the tag is 'file', the type could still be FileLinkMetadataReference | SharedLinkMetadataReference so I get a warning if I try to access the 'size' poperty.
I've worked around it with casting but I think it would be better if the SharedLinkMetadataReference was removed from the API declaration - it's not needed because typescript already knows what the common fields are
--- Tim
- Greg-DB9 months ago
Dropbox Community Moderator
Thanks for the feedback! I'll send this along to the team, but I can't promise if/when that change would be implemented.
About Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!