Simplify file upload processing logic

Streamline the file upload handling in RelayEnvironment by removing
redundant hasOwnProperty checks when processing uploadables. These
checks were unnecessary since we're already iterating through the keys
of the object. This change reduces code verbosity while maintaining
the same functionality.

Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
gearnode
2025-02-28 11:18:47 +01:00
parent cfabe3ee80
commit 7329039b32

View File

@@ -32,17 +32,13 @@ const fetchRelay: FetchFunction = async (request, variables, _, uploadables) =>
} = {};
Object.keys(uploadables).forEach((key, index) => {
if (Object.prototype.hasOwnProperty.call(uploadables, key)) {
uploadableMap[index] = [`variables.${key}`];
}
uploadableMap[index] = [`variables.${key}`];
});
formData.append('map', JSON.stringify(uploadableMap));
Object.keys(uploadables).forEach((key, index) => {
if (Object.prototype.hasOwnProperty.call(uploadables, key)) {
formData.append(index.toString(), uploadables[key]);
}
formData.append(index.toString(), uploadables[key]);
});
requestInit.body = formData;