私のデータがバックエンドに保存されているにもかかわらず、送信ボタンをクリックするとコンソールでこのエラーが表示されます。ここで位置0のJSONで予期しないトークンT
SyntaxError: Unexpected token T in JSON at position 0
at JSON.parse (<anonymous>)
at dc (angular.min.js:91)
at angular.min.js:92
at q (angular.min.js:7)
at gd (angular.min.js:92)
at f (angular.min.js:94)
at angular.min.js:131
at m.$digest (angular.min.js:142)
at m.$apply (angular.min.js:146)
at l (angular.min.js:97)
は角
再び$scope.nextStep = function() {
if ($scope.selection === 'Information'){
$scope.branch.organisation = $scope.branch.organisation.id;
$scope.fact.incrementStep($scope);
}
else if ($scope.selection === 'Validation'){
var authdata = base64.encode($rootScope.globals.currentUser.user.phone + ':' + $scope.password.password);
if (authdata === $rootScope.globals.currentUser.authdata){
$scope.passwordMatch = true;
var branchArr = [];
var dynamicBranches = $scope.dynamicBranches;
for (var i = 0; i < dynamicBranches.length; i++) {
branchArr.push(dynamicBranches[i].name);
}
var params = [{
"region" : $scope.branch.region,
"branches" : branchArr
}];
Restangular.one('organisation', $scope.branch.organisation).all('add_region_and_branch_data').post(params).then(function(response) {
$scope.createdBranch = response;
$scope.fact.incrementStep($scope);
}, function(error){
///console.log('Error with status', error.statusText, 'code', error.status);
//SweetAlert.swal('Error', 'The agent couldn\'t be created. \n' + error.data.error, 'error');
console.log(error);
});
}else{
$scope.passwordMatch = false;
}
}
};
で私のフロントエンドのコードで、私のデータは、APIに救われているが、私はこのエラーを取得しています。どうすればこの問題を解決できますか?
警告を。あなたのサービスは何を返すのですか?彼らの側に何らかのエラーがあるため、おそらく無効なJSONです。 –