mirror of
https://github.com/arnaucube/commonroutesApp.git
synced 2026-02-07 03:26:44 +01:00
token added in the petittions
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
var urlapi="http://localhost:3000/api/";
|
var urlapi="http://localhost:3000/api/";
|
||||||
//var urlapi="http://192.168.1.40:3000/api/";
|
//var urlapi="https://collectivecar.paas.primustech.io/api/";
|
||||||
|
|
||||||
|
|
||||||
//localStorage.setItem("c_username", "user2");
|
//localStorage.setItem("c_username", "user2");
|
||||||
//localStorage.setItem("c_token", "");
|
//localStorage.setItem("c_token", "");
|
||||||
|
|
||||||
@@ -112,6 +114,17 @@ angular.module('starter.controllers', [])
|
|||||||
|
|
||||||
|
|
||||||
.controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading) {
|
.controller('TravelsCtrl', function($scope, $http, $ionicModal, $timeout, $ionicLoading) {
|
||||||
|
if(localStorage.getItem('c_token')){// adding token to the headers
|
||||||
|
//console.log("token added to headers in run module");
|
||||||
|
//console.log($http.defaults);
|
||||||
|
$http.defaults.headers.post['X-Access-Token'] = localStorage.getItem('c_token');
|
||||||
|
//$http.defaults.headers.post['Content-Type'] = "application/x-www-form-urlencoded; charset=UTF-8";
|
||||||
|
//console.log($http.defaults.headers);
|
||||||
|
}
|
||||||
|
/*if(localStorage.getItem('c_token')){// adding token to the headers
|
||||||
|
$http.defaults.headers.token = localStorage.getItem('c_token');
|
||||||
|
}*/
|
||||||
|
|
||||||
$scope.travels="";
|
$scope.travels="";
|
||||||
|
|
||||||
$scope.travels=JSON.parse(localStorage.getItem('c_travels'));
|
$scope.travels=JSON.parse(localStorage.getItem('c_travels'));
|
||||||
@@ -134,8 +147,17 @@ angular.module('starter.controllers', [])
|
|||||||
$ionicLoading.show({ template: 'Travels actualized from server!', noBackdrop: true, duration: 2000 });
|
$ionicLoading.show({ template: 'Travels actualized from server!', noBackdrop: true, duration: 2000 });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.newtravel={};
|
$scope.newtravel={};
|
||||||
|
/*$scope.newtravel={
|
||||||
|
title: "prova",
|
||||||
|
from: "prova",
|
||||||
|
to: "prova",
|
||||||
|
seats: 3,
|
||||||
|
package: true,
|
||||||
|
phone: 123,
|
||||||
|
telegram: "telusr",
|
||||||
|
description: "this is the description of prova"
|
||||||
|
};*/
|
||||||
|
|
||||||
// Create the login modal that we will use later
|
// Create the login modal that we will use later
|
||||||
$ionicModal.fromTemplateUrl('templates/newofferingtravel.html', {
|
$ionicModal.fromTemplateUrl('templates/newofferingtravel.html', {
|
||||||
@@ -189,6 +211,7 @@ angular.module('starter.controllers', [])
|
|||||||
$scope.newtravel.owner=localStorage.getItem("c_username");
|
$scope.newtravel.owner=localStorage.getItem("c_username");
|
||||||
|
|
||||||
$scope.newtravel.modality="offering";
|
$scope.newtravel.modality="offering";
|
||||||
|
//$scope.newtravel.token=localStorage.getItem("c_token");
|
||||||
console.log($scope.newtravel);
|
console.log($scope.newtravel);
|
||||||
$http({
|
$http({
|
||||||
url: urlapi + 'travels',
|
url: urlapi + 'travels',
|
||||||
|
|||||||
Reference in New Issue
Block a user