Category : api

My Laravel API is hosted on godaddy and I am call that API from localhost. Here is $.ajax({ url: ‘https://example.com/api/ali’, method: ‘POST’, data: { image: dataURL, patientname: $(‘.patientname’).attr(‘patientname’), phone: phonenum, mrid: $(‘.patientmrid’).attr(‘mrid’), }, success: function(response) { $(".btnsave").text(‘Send message’); if(response == "success"){ $(‘.alert-success’).fadeIn(300).delay(5000).fadeOut(1000); }else if(response == "notsaved"){ $(‘.alert-danger’).fadeIn(300).delay(5000).fadeOut(1000); }else if(response == "notsent"){ $(‘.alert-danger’).fadeIn(300).delay(50000).fadeOut(1000); } }, error: ..

Read more

Vue console error log Am getting this 422 (Unprocessable Entity) error while trying to do a POST request using Laravel and Vue-resource. I currently have the following codes: register() { this.loading = true; this.axios.post(‘register’, { firstname: this.firstname, lastname: this.lastname, email: this.email, password: this.password, password_confirmation: this.password_confirmation }) .then(response => { this.loading = false; this.name = ”; ..

Read more

I using laravel api resource for my FRONT-END site. Actually i using also laravel pagination to handle paginate in FRONT-END. The api resource structure like this: { "data": […], "links": […], // handle pagination "meta": […] // handle pagination } But i want to send count of query results without considering paginating .For example i ..

Read more

maybe i have a thinking error. Maybe not. I want to create a API token for my application. The following scenerio i want to do: I have a Laravel application and now i want to code a mobile app. In the mobile app a user can register. For this i want to have n API ..

Read more

I have a problem about decodable the "product" from laravel api request. Error is "The data couldn´t be read because it isn´t in the correct format. request with insomnia is right and i get the product where the ean number has. Laravel for database: Schema::create(‘products’, function (Blueprint $table) { $table->id(); $table->bigInteger(‘ean’); $table->string(‘name’); $table->string(‘manufacturer’); $table->string(‘productNumber’); $table->longText(‘description’)->nullable(); ..

Read more

here is my controller code: public function tournaments() { $data = 0; $response = Http::withHeaders( [ ‘x-rapidapi-host’=> ‘uxxxx’, ‘x-rapidapi-key’=> ‘asdfasdfas’, ] )->get(‘https://unibet.p.rapidapi.com/competitions-by-sport/football’); return $response; } and response message received: {"message":"Missing required parameters"} How can i add parameters to these code? for exmpl: params: {sport: ‘football’}, And maybe someone could share a tutorial video on how ..

Read more

I’m planning to randomize the order of my query on quiz_question and choices but the quiz_question is the only one who gets randomized but the choices are still the same. This is my code : class QuestionByQuizID extends Controller { public function index(int $quiz_id){ $questions = quizQuestions::where(‘quiz_id’, ‘=’, $quiz_id)->with([‘choices’])->inRandomOrder()->get(); if(is_null($questions)){ return response()->json(‘Record not found!’, 401); ..

Read more

I am trying to get latest messages from table ‘messages’ for inbox The chat is between user and owner of the item (listed on my portal) I want to get unique data with item_id My code is public function inbox() { // $inbox = ChatMessage::distinct(‘item_id’)->where(‘incoming_msg_id’, auth()->user()->id)->orWhere(‘outgoing_msg_id’, auth()->user()->id)->orderBy(‘msg_id’, ‘DESC’)->get(); $inbox = Message::where(‘incoming_msg_id’, auth()->user()->id)->orWhere(‘outgoing_msg_id’, auth()->user()->id)->latest(‘msg_id’)->get()->unique(‘item_id’); return $this->sendResponse($inbox,’Chat’); ..

Read more

Thanks for your help. In my projet laravel api(v8) if I send an email in function, api always return false, but I can receiver my email. Mail::to(‘customer_email’)->send(’email contract’); if I remove function email, I can get reponse json, api works very well. I think problem in function "laravel Mail", but I don’t understand why ? ..

Read more

$client = new Client(); $response = $client->request( ‘POST’, /*instead of POST, you can use GET, PUT, DELETE, etc*/ ‘https://api.sandbox.ebay.com/identity/v1/oauth2/token’, [ ‘headers’ => [ ‘Content-Type’=>’application/x-www-form-urlencode’, ‘Authorization’=>’Basic ‘.base64_encode(‘<‘.env(‘EBAY_CLENT_APP_ID’).’>:<‘.env(‘EBAY_CLENT_APP_SECRET’).’>’), ], ‘form_params’ => [ ‘grant_type’ => ‘authorization_code’, ‘code’ => $req->code, ‘redirect_uri’ => env(‘EBAY_REDIRECT_URI’) ] ] ); $output = json_decode($response->getBody()); dd($output); I am using guzzlehttp 7.4 and laravel 8.65. All ..

Read more

I deployed frontend and backend in a shared hosting. When I call api, then shows this errors in browser console. xhr.js:210 Mixed Content: The page at ‘https://front.thecomicden.com/’ was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ‘http://back.thecomicden.com/api/allTask’. This request has been blocked; the content must be served over HTTPS. createError.js:16 Uncaught (in promise) Error: ..

Read more

I am using Tabulator 4.6 and I have an api with POST method and I want to fetch tabulator data through POST request not GET. In my org.js is like: var ajaxConfig = { mode: "no-cors", method: "POST", //set request type to Position headers: { "Content-type": ‘application/json; charset=utf-8’, "X-CSRF-TOKEN": $(‘meta[name="csrf-token"]’).attr(‘content’), "Access-Control-Allow-Origin": ‘*’ }, var ajaxParams ..

Read more

Laravel usually use following for request validation. $request->validate([ ‘name’ => [‘required’, ‘string’, ‘max:255′], ’email’ => [‘required’, ‘string’, ’email’, ‘max:255’, ‘unique:users’, ‘required_without_all:phone’], ‘password’ => [‘required’, ‘confirmed’, RulesPassword::defaults()], ‘phone’ => [‘required’, ‘string’, ‘max:13’, ‘unique:users’, ‘required_without_all:email’], ]); This method only add $error variable that can be access using blade files as it render on server only. But now ..

Read more