My directive, known as machineForm
, includes a dataService
:
dataService.getMachineTaxesById($scope.machineId).then(function (response) {
$scope.machine.machineTaxes = response.data;
});
I am using this directive twice simultaneously.
<div class="modal-compare-item">
<machine-form app-data="appData"
index="analyzie_index"
machine-id="machineAnalyze.id"
machine="machineAnalyze"
action="'edit'">
</machine-form>
</div>
<div class="modal-compare-item">
<machine-form app-data="appData"
index="compare_index"
machine-id="machineCompare.id"
machine="machineCompare"
action="'edit'">
</machine-form>
</div>
The dataService
function for getMachineTaxesById
is shown below:
// Get Machine Taxes By Id
this.getMachineTaxesById = function(machine_id) {
return $http({
method: 'GET',
url: 'https:xyz/api/MachineTaxes/Machine/'+ machine_id,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization' : $cookies.get('token_type') + " " + $cookies.get('access_token')
}
});
};
If I comment out one of the <machine-form>
instances, everything works fine. However, when both are called concurrently, I receive this error message in the response
:
{"message":"Authorization has been denied for this request."}
Could this issue be related to sending parallel requests? Should I wait for one request to finish before sending the other?
Note: An access token is used for each request.