We've updated the Appwrite JavaScript SDKs to support object-based arguments instead of positional ones.
This change makes SDK calls easier to read, less error-prone, and more maintainable.
Before (positional arguments):
JavaScript
const result = storage.getFilePreview( '<BUCKET_ID>', '<FILE_ID>', undefined, // width undefined, // height ImageGravity.Center, undefined, // quality undefined, // borderWidth undefined, // borderColor undefined, // borderRadius undefined, // opacity undefined, // rotation undefined, // background ImageFormat.Jpg, '<TOKEN>');// Required passing undefined for unused optional parametersAfter (object arguments):
JavaScript
const result = storage.getFilePreview({ bucketId: '<BUCKET_ID>', fileId: '<FILE_ID>', gravity: ImageGravity.Center, output: ImageFormat.Jpg, token: '<TOKEN>'});// No more undefined values needed!What about existing code?
Positional arguments still work, but they've been marked as deprecated. Your IDE will show warnings, and you can migrate over time.
This update is now available in the following SDK versions:
appwrite@19.0.0(Web)node-appwrite@18.0.0(Node.js)react-native-appwrite@0.12.0(React Native)