Fixed issue related to postman environment imports failure (#4523)

This commit is contained in:
Anoop M D 2025-04-18 21:33:12 +05:30 committed by GitHub
commit 56ab61c29c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 3 deletions

View File

@ -28,7 +28,10 @@ const ImportEnvironment = ({ collection, onClose }) => {
.then(() => {
toast.success('Environment imported successfully');
})
.catch(() => toast.error('An error occurred while importing the environment'));
.catch((error) => {
toast.error('An error occurred while importing the environment');
console.error(error);
});
});
})
.then(() => {

View File

@ -34,7 +34,10 @@ const ImportEnvironment = ({ onClose }) => {
.then(() => {
toast.success('Global Environment imported successfully');
})
.catch(() => toast.error('An error occurred while importing the environment'));
.catch((error) => {
toast.error('An error occurred while importing the environment');
console.error(error);
});
});
})
.then(() => {

View File

@ -5,7 +5,15 @@ import { postmanToBrunoEnvironment } from '@usebruno/converters';
const readFile = (files) => {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.onload = (e) => resolve(e.target.result);
fileReader.onload = (e) => {
try {
let parsedPostmanEnvironment = JSON.parse(e.target.result);
resolve(parsedPostmanEnvironment);
} catch (err) {
console.error(err);
reject(new BrunoError('Unable to parse the postman environment json file'));
}
}
fileReader.onerror = (err) => reject(err);
fileReader.readAsText(files[0]);
});