use colar for multiple api requests Laravel - laravel

I do not have much experience, I have the following problem with an api that receives multiple requests I would like to implement laravel queues to give a better response to those multiple requests, but I do not know how to do it.
thanks
my controller
enter image description here
my jobs
enter image description here

Related

Best practice to retrieve multiple pages from API?

I am working on a Springboot microservice that interacts with a 3rd-party API. The API returns a paged response but I will have to retrieve multiple pages depending on the response. What would the best way to do so? The most naive way I could think of is to retrieve all the pages first and then work with them rather than processing the pages one at a time.

Laravel application response with 429 http-status-code

I have a web application (Angular front, Laravel backend API). In that there is a section where I have messaging system. Basically four user roles can post and read messages.
When a user logged in I needs to check every 10 seconds to see if there are new messages for any user of any role(out of 4 roles).
This works fine but from time to time I get http status code of 429 Too many request. I have no idea what is the reason. Anyone have an idea of what is the reason or can point me to the right direction in order to fix this?
Note: I have a custom field system build and I use that to hold extra data of messages. I notice that when i fetch messages considerable number of models related to custom fields also quarried. Can this be a reason?
I found the solution and here are my steps.
I needed to find all my request going to the API, for that I installed this package API logger. Using this I examined the requests and there I found some request made to the API over and over.
I corrected the requests made to the API and the issue seems to fixed.

Prevent many requests initially with SPA

I am currently developing a web app using vue. When my app starts it makes several requests to my api to get necessary resources.
await Promise.all([
store.dispatch('setUserOnStartup'),
store.dispatch('getAds'),
store.dispatch('getCompanies'),
store.dispatch('getCities')
]);
I am just wondering if you usually try to prevent this in your apps? If you make an endpoint where you get all the initial resources at once? For ex: /api/initial
Are there any other ways to prevent this or is it fine to do my approach with several requests initially?
Thanks in advance.
JSON API to the rescue.
You can fetch all you need with single request, if all entities you need are related. See http://jsonapi.org/format/#fetching-includes for details.

How to store data in VueJS with Laravel 5.4

Im building application like real time dashboard. Using many databases and external APIs.
(The first Idea was AJAX + Laravel Queues, but I found VueJS and It's interesting.)
The idea is to get the data in background with Laravel Queues from all sources and then storage it localy. Next step is getting this data with VueJS.
The problem I have is the storage part. I dont have idea and actually dont know how to store it so VueJS can efficiently get this data from storage and on the other hand Laravel can save the data to it the same.
There will be many users loging in a system so I created the MySQL database for them but dont know, if it's a good solution.
Thanks for advices!
You create routes for Vue.js to make XHR(Ajax) requests to. If you want to save data this would be a post route. If you want to retrieve data this would be a get route.
How you handle the data you are sending or (directly)receiving is of no concern to Vue.js.
This would be a good start:
https://laracasts.com/series/learn-vue-2-step-by-step/episodes/18

POSTing entities to WebAPI in batch?

Do I need to send individual entity updates to WebAPI, or can I POST an array of them and send them all at once? It seems like a dumb question, but I can't find anything that says one way or another.
Brad has a blog post that talks about implementing batching support in Web API.
Also, Web API samples project on codeplex has a sample for doing batching in web API hosted on asp.net.
It seems like WEB API 2 has support for this
From the site (Web API Request Batching):
Request batching is a useful way of minimizing the number of messages
that are passed between the client and the server. This reduces
network traffic and provides a smoother, less chatty user interface.
This feature will enable Web API users to batch multiple HTTP requests
and send them as a single HTTP request.
There are a number of samples for different scenarios on this page.
https://aspnetwebstack.codeplex.com/wikipage?title=Web+API+Request+Batching
You will have to create an action that accepts a collection of items.
If all you have is an action that accepts a single item than you need to send separate requests.
With batching always think about how you would report the failures and whether a failing of a single item should invalidate the whole batch.

Resources