app.blade.php:
<script>
window.Laravel = <?php echo json_encode([
'csrfToken' => csrf_token(),
]); ?>
Laravel.apiToken = "{ Auth::check() ? 'Bearer '.Auth::user()->api_token : 'Bearer ' }";
</script>
bootstrap.js:
Vue.http.interceptors.push((request, next) => {
request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken);
request.headers.set('Authorization', Laravel.apiToken);
next();
});
值可以获取到,但是就是不能点击关注按钮,
<script>
window.Laravel = {"csrfToken":"Aq2ztvmUKPzAr79MaqrRKbsQojLtLXqJv0kVKzvQ"}
Laravel.apiToken = "Bearer a7QDv8acuI13hOW7aYEITerZb7Q9B17IeAUjV43Vy1WQE7yVTEXipyFDv9ZU";
</script>