const token = $v('P12_TOKEN');
fetch('https://gw.fbr.gov.pk/di_data/v1/di/postinvoicedata', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
// Dummy data for API Testing
test: true
})
})
.then(response => {
// Agar server response de raha hai (chahe 200 ho ya 400 Bad Request)
console.log('Status Code:', response.status);
return response.json().catch(() => ({})); // Safe Fallback if JSON Not Available
})
.then(data => {
console.log('API Response:', data);
apex.message.alert('API is Live and Responding!');
})
.catch(error => {
// This will Run if network or API is down/unreachable
apex.message.alert('Alert: FBR API Not Responding / Network Error..!');
console.error('Error:', error);
});
No comments:
Post a Comment