Category : axios

This is my Laravel PenilaianController: public function index() { // $penilaian1 = PenilaianTahap1::join(‘peserta_t1’, ‘nilai_t1.nim’, ‘=’, ‘peserta_t1.nim’) ->join(‘pendaftar’, ‘peserta_t1.nim’, ‘=’, ‘pendaftar.nim’) ->join(‘sub_kriteria_t1’, ‘nilai_t1.id_sk1’, ‘=’, ‘sub_kriteria_t1.id_sk1’) ->join(‘kriteria_t1’, ‘sub_kriteria_t1.id_k1’, ‘=’, ‘kriteria_t1.id_k1’) ->get([ ‘nilai_t1.nim’, ‘pendaftar.nama’, ‘nilai_t1.nilai’, ‘nilai_t1.id_sk1’ ]); $subkriteria = SubKriteriaTahap1::join(‘kriteria_t1’, ‘sub_kriteria_t1.id_k1’, ‘=’, ‘kriteria_t1.id_k1’) ->get([ ‘sub_kriteria_t1.sub_kriteria’, ‘sub_kriteria_t1.bobot’, ]); $kriteria = KriteriaTahap1::all(); $response = [ ‘message’ => ‘Data pendaftar OR ..

Read more

This is my Laravel PenilaianController: public function index() { // $penilaian1 = PenilaianTahap1::join(‘peserta_t1’, ‘nilai_t1.nim’, ‘=’, ‘peserta_t1.nim’) ->join(‘pendaftar’, ‘peserta_t1.nim’, ‘=’, ‘pendaftar.nim’) ->join(‘sub_kriteria_t1’, ‘nilai_t1.id_sk1’, ‘=’, ‘sub_kriteria_t1.id_sk1’) ->join(‘kriteria_t1’, ‘sub_kriteria_t1.id_k1’, ‘=’, ‘kriteria_t1.id_k1’) ->get([ ‘nilai_t1.nim’, ‘pendaftar.nama’, ‘nilai_t1.nilai’, ‘nilai_t1.id_sk1’ ]); $subkriteria = SubKriteriaTahap1::join(‘kriteria_t1’, ‘sub_kriteria_t1.id_k1’, ‘=’, ‘kriteria_t1.id_k1’) ->get([ ‘sub_kriteria_t1.sub_kriteria’, ‘sub_kriteria_t1.bobot’, ]); $kriteria = KriteriaTahap1::all(); $response = [ ‘message’ => ‘Data pendaftar OR ..

Read more

anyone knows how to submit file with bootstrapVue file input? I am getting null from request->all() array:13 [ … "calibration_cert" => array:1 [ "$path" => null ] ] Below is what I tried <b-form-group label="Calibration Cert:"> <b-form-file v-model="form.calibration_cert" :state="Boolean(form.calibration_cert)" placeholder="Choose a file or drop it here…" drop-placeholder="Drop file here…" ></b-form-file> </b-form-group> ….. methods:{ onSubmit(event) { ..

Read more

So here’s my problem : I use the EOD Financial api to get data on a stock, on a Laravel/Vue.js project. On a Vue Component, I use axios to make a get Request like this : const response1 = await axios.get("/getHistoricalDataNAME/"+String(self.stock.code)+’.’+String(self.stock.exchange)) .then((response) => { with the function getHistoricalDataNAME being : public function getHistoricalDataISIN(String $ISIN) { ..

Read more

I built Laravel APIs and hosted on namecheap. I have set up the handleCORS file with these attributes: ‘paths’ => [‘api/*’], ‘allowed_methods’ => [‘*’], ‘allowed_origins’ => [‘*’], ‘allowed_origins_patterns’ => [‘*’], ‘allowed_headers’ => [‘*’], ‘exposed_headers’ => [], ‘max_age’ => 0, ‘supports_credentials’ => true, On the frontend, my requests are made using axios with the only header ..

Read more

I tried to sent api request from Nuxt to Laravel. On my nuxt i have axios configured like this: export default function({$axios, store}, inject){ var base_url = "http://api-test.test/api"; inject(‘api’, function(){ const axios_api = $axios.create() axios_api.setBaseURL(base_url); axios_api.setHeader(‘Accept’, ‘application/json’, ‘common’); axios_api.setHeader(‘Content-type’, ‘application/json’, ‘common’); return axios_api; }); } And my post request is : var formData = new ..

Read more

I saw in the docs I need to first get a CSRF token from the API endpoint localhost:8080/sanctum/csrf-cookie: https://laravel.com/docs/8.x/sanctum#spa-configuration I do it like so: useEffect(() => { axios.get(‘http://localhost:8080/sanctum/csrf-cookie’).then(response => { console.log(JSON.stringify(response)) }); }, []); I do get the response which is: register.jsx?{"data":"","status":204,"statusText":"No Content","headers":{"cache-control":"no-cache, private"},"config":{"url":"http://localhost:8080/sanctum/csrf-cookie","method":"get","headers":{"Accept":"application/json, text/plain, /"},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false}},"request":{}} But then when I try to pass data to ..

Read more

I saw in the docs I need to first get a CSRF token from the API endpoint localhost:8080/sanctum/csrf-cookie: https://laravel.com/docs/8.x/sanctum#spa-configuration I do it like so: useEffect(() => { axios.get(‘http://localhost:8080/sanctum/csrf-cookie’).then(response => { console.log(JSON.stringify(response)) }); }, []); I do get the response which is: register.jsx?{"data":"","status":204,"statusText":"No Content","headers":{"cache-control":"no-cache, private"},"config":{"url":"http://localhost:8080/sanctum/csrf-cookie","method":"get","headers":{"Accept":"application/json, text/plain, /"},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false}},"request":{}} But then when I try to pass data to ..

Read more

I changed from Axios to Inertiajs Request: So my question is how to Handle the Responses, As I want to eg. Toast the ‘message’ on Success The princip I think of CreateController(): createController() { return Redirect::route(‘company.index’, [ // Add props to index() Request ‘message’ => ‘Organization has been created!’, ‘newOrganisation’ => $newOrganisation, ]); } Compared: ..

Read more

GET routes work when set up like so: $router->get(‘/user/{id}’, [‘uses’ => ‘[email protected]’]); And using this CorsMiddleware.php public function handle(Request $request, Closure $next) { $headers = [ ‘Access-Control-Allow-Origin’ => ‘*’, ‘Access-Control-Allow-Methods’ => ‘POST, GET, OPTIONS, PUT, DELETE’, ‘Access-Control-Allow-Credentials’ => ‘true’, ‘Access-Control-Max-Age’ => ‘86400’, ‘Access-Control-Allow-Headers’ => ‘Content-Type, Authorization, X-Requested-With’ ]; if ($request->isMethod(‘OPTIONS’)) { return response()->json(‘{"method":"OPTIONS"}’, 200, $headers); ..

Read more

The file that I am generating is being returned in the response as a string instead of prompting the download. I’ve seen and tried a couple approaches to it from stackoverflow / other websites and they ultimately all resulted in the exact same problem. I’ve tried: Making a temp file, writing to it, then moving ..

Read more

So I’m using Laravel 8 and Vuejs 3, I have Route::get in my web.php that call method that are in my controller which fecth data from database and ont the Vue side, I have an axios get request that get the url to retrieve the data. Route::get(‘/trainee’,[UserController::class,’getTrainees’]); Route::get(‘/instructor’,[UserController::class,’getInstructors’]); Route::get(‘/acpCenter’,[AcpCenterController::class,’getAcpCenter’]); Thos are some of my routes ..

Read more

I have Vue3 application with Access-Control-Allow-Origin header set up according documentation for the package which sends this headers. Every common requests have this headers but if the form request fails then Access-Control-Allow-Origin header is not included in the response. It throws an error Access to XMLHttpRequest at ‘https://tatrytec.eu/api/article/store/’ from origin ‘https://vue.tatrytec.eu’ has been blocked by ..

Read more