Configure axios library and read the api-key dynamically
This commit is contained in:
@@ -1,28 +1,18 @@
|
||||
@section('scripts')
|
||||
<script>
|
||||
$(document).ready(() => {
|
||||
const select_id = "select#aircraft_select";
|
||||
const destContainer = $('#fares_container');
|
||||
<script>
|
||||
const select_id = "select#aircraft_select";
|
||||
const destContainer = $('#fares_container');
|
||||
|
||||
$(select_id).change((e) => {
|
||||
const aircraft_id = $(select_id + " option:selected").val();
|
||||
console.log('aircraft select change: ', aircraft_id);
|
||||
$(select_id).change((e) => {
|
||||
|
||||
$.ajax({
|
||||
url: "{{ url('/pireps/fares') }}?aircraft_id=" + aircraft_id,
|
||||
type: 'GET',
|
||||
headers: {
|
||||
'x-api-key': '{{ Auth::user()->api_key }}'
|
||||
},
|
||||
success: (data) => {
|
||||
console.log('returned new fares', data);
|
||||
destContainer.html(data);
|
||||
},
|
||||
error: () => {
|
||||
destContainer.html('');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
const aircraft_id = $(select_id + ' option:selected').val();
|
||||
const url = '{{ url('/pireps/fares') }}?aircraft_id=' + aircraft_id;
|
||||
console.log('aircraft select change: ', aircraft_id);
|
||||
|
||||
axios.get(url).then(response => {
|
||||
console.log('returned new fares', response);
|
||||
destContainer.html(response.data);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user