Category : post

This is my error. xhr.js:210 POST http://localhost:8000/api/addproduct 500 (Internal Server Error) AddProduct.js:18 Error: Request failed with status code 500 at createError (createError.js:16) at settle (settle.js:17) at XMLHttpRequest.onloadend (xhr.js:66) My post request from react component(AddProduct) for post request, I used axios. and get this error not posting data to DB. const formData = new FormData(); formData.append("name", ..

Read more

I’m making a post request with postman that works: curl –location –request POST ‘https://example.com/v1/oauth2/token’ –header ‘Authorization: Basic ZjLWMyMmItNDk1MS04ZjQzLTNlZmM1NDAyZjkzZA==’ –header ‘Content-Type: application/x-www-form-urlencoded’ –data-urlencode ‘grant_type=client_credentials’ I’m trying to do it with Laravel 8: $res = Http::withBasicAuth("user", "***") ->withOptions([ ‘debug’ => true, ‘verify’ => false]) ->withHeaders([ "Content-Type"=> "application/x-www-form-urlencoded" ]) ->post(env("URL") . "/v1/oauth2/token", [ ‘form_params’ => [ ‘grant_type’ => ..

Read more

register.blade.php <form class="" action="/register" method="post"> @csrf <div class="row"> <div class="col-12 col-sm-6"> <div class = "form-group"> <label for="firstname">First Name</label> <input type = "text" class="form-control" name="firstname" id="firstname" value="{{ old(‘firstname’) }}"> </div> </div> … <div class="row"> <div class="col-12 col-sm-4"> <button type="submit" class="btn btn-primary">Register</button> </div> <div class="col-12 col-sm-8 text-right"> <a href="/">Already have an account?</a> </div> </div> {!! csrf_field() !!} ..

Read more

I am learning laravel and php in general and I came upon using Laravel passport as authentication. I followed the documentation to replace the values in various config files. My Controller’s login function: public function login(Request $request) { $credentials = [ ’email’ => $request->email, ‘password’ => $request->password ]; if (auth()->attempt($credentials)) { $token = auth()->user()->createToken(‘[email protected]’)->accessToken; return ..

Read more

I’m new-ish to Laravel. I have this form : <form action="{{ route(‘foo.store’, [‘idFoo’ => $foo->id]) }}" method="POST" accept-charset="UTF-8"> and this route : Route::post(‘/foo/store/{idFoo}’, [AppHttpControllersFooController::class, ‘fooStore’])->name(‘foo.store’); Also, I added the @csrf, it’s not the problem. So, when this route is used, it renders a blank page , but if I change both "post" to "get", it ..

Read more

I’m new-ish to Laravel. I have this form : <form action="{{ route(‘foo.store’, [‘idFoo’ => $foo->id]) }}" method="POST" accept-charset="UTF-8"> and this route : Route::post(‘/foo/store/{idFoo}’, [AppHttpControllersFooController::class, ‘fooStore’])->name(‘foo.store’); Also, I added the @csrf, it’s not the problem. So, when this route is used, it renders a blank page , but if I change both "post" to "get", it ..

Read more

Please check the following code for rate limiter RateLimiter::for(‘api’, function (Request $request) { return [ // Rate limiter based on Client IP Address Limit::perMinute(env(‘IP_ADDR_RATE_LIMITER_PER_MINUTE’, 60))->by($request->ip())->response(function () { …. }), // Rate limiter based on API key/User Limit::perMinute(env(‘API_KEY_RATE_LIMITER_PER_MINUTE’, 60))->by($request->input(‘key’))->response(function () { … }) ]; }); Route config in api.php Route::post(‘/temporalrisk/v1’, [TemporalRouteRiskV1::class, ‘postMethod’])->middleware(‘key’)->name(‘temporalrouteriskv1.index’); Can someone help me ..

Read more

I have seen/worked on lot of projects where a Laravel POST route looking like this: Route::post(‘/some-url’, [SomeController::class, ‘someMethod’]); And the controller with its method which takes care of the route looking like this: class SomeController extends Controller { public function someMethod(Request $request) { // My Logic to do something with the post data – $request ..

Read more

I have included csrf_field() like below <form action="/submit" method="post" enctype="multipart/form-data"> {{csrf_field()}} // input fields </form> But i get 419 error for this. I tried clearing the cache also. But no luck. Only way i could fix this is to include this path to the app/http/middleware/VerifyCsrfToken.php I want to know why this happens and how do ..

Read more

I have a form at the Blade like this: @forelse($orders as $order) <form method="POST" action="{{ route(‘orders.newprint’, [‘id’=>$order->id]) }}"> @csrf <tr> <td><input class="form-check-input" name="orderCheck[]" type="checkbox" value="{{ $order->ord_id }}">&nbsp;</td> <td>{{ $order->ord_id }}</td> </tr> @empty <td colspan="7" class="text-center">Nothing to show</td> @endforelse <hr> <label>Actions:</label> <select class="form-control select2" name="actions" id="actions"> <option value="">Select…</option> <option value="print_factors">Print Factors</option> <option value="print_orders">Print Orders</option> </select> <button ..

Read more

I am currently trying to upload multiple files through an API endpoint. It’s a POST request, its body contains form-data. I am unable to get it through for each loop, though it works just fine if there’s no foreach and there’s only one file. Code that doesn’t work: $path = config(‘app.photos_dir’); if($request->hasFile(‘photos’)) { if (!file_exists($path)) ..

Read more

I am making signup form.In my routes web.php signnup and login function all working perfectly with GET when I use POST method in routes it throws an error. Here is my routes file: Route::get(‘/register-user’,[Logincontroller::class,’registration’]); Route::get(‘/login-user’,[Logincontroller::class,’logins’]); Route::post(‘/user-register’,[Logincontroller::class,’userregister’])->name(‘user-register’); My controller class Logincontroller extends Controller { public function logins() { return view("auth.login"); } public function registration() { return ..

Read more

this is my registration form and I tried to var_dump($_POST) and the result is nothing it shows me this array (size=0) empty I gave the attribute name to every input field I’m really sure it’s an very small thing that I dont think about this time. <form method="POST" action="{{url(‘register’)}}"> @csrf <h4 class="text-upper" data-inview-showup="showup-translate-right">InformaČ›ii personale</h4> <div ..

Read more

I’m trying to implement IPN in my Laravel project, a post request from my website is working thanks to "csrf", i try to implement it like written here: https://developer.paypal.com/docs/api-basics/notifications/ipn/ht-ipn/ in my routes/web.php: Route::post(‘i’, [IController::class, ‘y’])->name(‘i’); and in IController whats written on the side: public function y() { error_log(‘function y called’); // STEP 1: read POST ..

Read more

I want to call a route of the post method from the Laravel API part i.e. not from the blade file. this is my route Route::post(‘/logout’, [LogoutController::class, ‘destroy’])->name(‘logout’); This is destroy function in LogoutController class public function destroy(Request $request) {} I have tried with the below code. But these are not working. return redirect()->route(‘logout’, [‘request’ ..

Read more