We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
export const downloadSalarySlip = (request) => async (dispatch) => { try { const userinfo = await AsyncStorage.getItem('LoginData'); const token = JSON.parse(userinfo)?.token;
const response = await makeAPIRequest({ method: GET, url: `${api.downloadSalarySlipApi}?user_id=228`, headers: { 'Content-Type': 'application/pdf', Authorization: `Bearer ${token}`, }, responseType: 'arraybuffer', }); if (response?.data) { const filePath = `${RNFS.DocumentDirectoryPath}/SalarySlip_${Date.now()}.pdf`; console.log('File path:', filePath); const buffer = Buffer.from(response.data); await RNFS.writeFile(filePath, buffer.toString('base64'), 'base64'); console.log('File saved successfully at:', filePath); // Introduce a delay of 300ms before opening the file setTimeout(() => { FileViewer.open(filePath, { type: 'application/pdf' }) .then(() => { console.log('PDF opened successfully!'); if (request.onSuccess) request.onSuccess(filePath); }) .catch((error) => { console.error('Error opening PDF:', error); if (request.onFail) request.onFail('Error opening PDF'); }); }, 300); // 300ms delay } else { console.error('No data in API response'); if (request.onFail) request.onFail('No data in API response'); }
} catch (error) { console.error('Error downloading salary slip:', error); if (request.onFail) request.onFail(error.message); } };
I have tried adding delay of 300ms to manage but its still not working
The text was updated successfully, but these errors were encountered:
No branches or pull requests
export const downloadSalarySlip = (request) => async (dispatch) => {
try {
const userinfo = await AsyncStorage.getItem('LoginData');
const token = JSON.parse(userinfo)?.token;
} catch (error) {
console.error('Error downloading salary slip:', error);
if (request.onFail) request.onFail(error.message);
}
};
I have tried adding delay of 300ms to manage but its still not working
The text was updated successfully, but these errors were encountered: