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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user