shaqaruden

Experience

41,570

0 Best Reply Awards

  • Member Since 2 Years Ago
  • 410 Lessons Completed
  • 1 Favorite

13th January, 2018

shaqaruden started a new conversation Speeding Up Cache • 4 days ago

I am currently caching data from my API with WebStorageCache Now it is still taking a second or two to assign the data in the cache to a variable on my Vue component. I understand that when loading the 1400+ record object from cache will take time.

My question is how could I speed this up?

##My Thoughts

I know I can paginate the data coming from my API which I do have but currently have it disable because I don not know how I should go about caching it in a logical way.

Would I create separate caching objects for each paginated object returned from the API? Could that all be searchable?

Would I append to 1 cache object? How would I keep track of what has already been cached without making an axios call?

shaqaruden left a reply on Vuetify | Browser Tab Hangs When Using SessionStorage • 4 days ago

I fixed the issue before I got to looking at your reply. I ended up pulling in WebStorageCache

Using this my app performs much better. It still is not where I would like it. I disabled pagination on the API while I worked on this because I was not sure how I would handle caching sections of data. ( Caching each paginated result in a separate cache? Append to the cache?)

Here is my working code using WebStorageCache.

import WebStorageCache from 'web-storage-cache'

....

renderData (url) {

        var cache = new WebStorageCache();

        if (!cache.get('people')) {
            axios.get(url).then(response => {
                cache.set('people', response.data.people, {exp : 120});
            })
            .catch(e => {
                this.errors.push(e)
            })
        }
        
        this.associates = cache.get('people');
      }

Even after caching the page takes a second or two to retrieve from localStorage which I would like to remedy.

shaqaruden started a new conversation Vuetify | Browser Tab Hangs When Using SessionStorage • 5 days ago

I am trying to cache data from an API. With this specific request the API is returning 1440+ records which comes to around 600kb of data. I have this request wrapped in an if statement checking whether the data has been cached.

From look at the network tab in dev tools I can see that the request complete getting a status code 200 and receiving 626KB and I can check under Application/Session Storage/localhost:8080 and see the cached data but the sites doesn't not display the data like it should. If I navigation away from that page and back the tab hangs and eventually displays blank elements where the data should be.

Here is my code that handles the Session Storage

if (!sessionStorage.people) {
              axios.get(url)
                .then(response => {
                    sessionStorage.people = response.data.people;
                })
                .catch(e => {
                    this.errors.push(e)
                })
          }

          this.people= sessionStorage.people

this.people is bound to a vue component with a v-for.

<v-flex v-for="person in people" xs12 sm6 lg3>

11th January, 2018

shaqaruden started a new conversation Axios | Automatic Caching? • 6 days ago

Does Axios cache automatically? I don't remember if Jeffrey ever mentioned this.

9th January, 2018

shaqaruden left a reply on Post Method Not Allowed? • 1 week ago

@bobbybouwmann I didn’t changed anything.

8th January, 2018

shaqaruden left a reply on Error: "Your Requirements Could Not Be Resolved To An Installable Set Of Packages." • 1 week ago

I had a similar issue with a linux fork of Laravel Valet (cpriego/valet-linux) for Linux and the solution for me was to simply install Symfony Process 3.4.3 explicitly with composer.

composer global require symfony/process:3.4.3

shaqaruden left a reply on Post Method Not Allowed? • 1 week ago

I filled out my form data again in Postman and this fixed my issue

23rd December, 2017

shaqaruden left a reply on Post Method Not Allowed? • 3 weeks ago

I don’t have the code on me but I did check that and there is a route for a post request to API/workcenter that calls the [email protected] method

22nd December, 2017

shaqaruden started a new conversation Post Method Not Allowed? • 3 weeks ago

I have created a resource controller using artisan and made a resource route group as well,

Route::resource('workcenter', 'WorkcenterController');

Using Postman I make a post request to /api/workcenter which should call the store() method on my controller but its calling the index() method instead. I commented my resource route and made a single route for the post method to the same URI and I get a

Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException

21st December, 2017

shaqaruden left a reply on API Route Model Binding | Exception Handling • 4 weeks ago

@burlresearch I got this working. My code is a lot cleaner now. Thank!

shaqaruden left a reply on API Route Model Binding | Exception Handling • 4 weeks ago

I will check the logs tomorrow but it seems to be an issue with brewing up the AssociateCo troller

20th December, 2017

shaqaruden left a reply on API Route Model Binding | Exception Handling • 4 weeks ago

@martinbean Thank you for the clarification.

@burlresearch I tried your method but when I am getting a Internal Error Code 500

shaqaruden left a reply on API Route Model Binding | Exception Handling • 4 weeks ago

@martinbean as I stated in one of my previous replies that I did have laravel returning json but it was not the response I wanted. I did not want the stack trace just a simple json response.

@burlresearch thanks! I will try this a little later today.

19th December, 2017

shaqaruden left a reply on API Route Model Binding | Exception Handling • 4 weeks ago

@Cronix I tried placing this code in my App\Exceptions\Handler.php under the render function

if ($exception instanceof NotFoundHttpException) {
            return Response::json('Error');
        }

but this does not work, is there a way i could get send this back to the controller to be handled?

I don't need to use Route Model Binding but I was thinking that I must be able to do this.

shaqaruden left a reply on API Route Model Binding | Exception Handling • 4 weeks ago

@burlresearch You see when an associate is not found it redirects to the 404 page. Now if I set the Accept and Content-Type Headers to application/json I then get a json response but it includes the stack trace and all i really want it

{
    "error": {
        "message": "Associate does not exist.",
        "status_code": 404
    }
}

shaqaruden left a reply on API Route Model Binding | Exception Handling • 4 weeks ago

This is what I am doing

public function show($assoc)    
    {
        
        $associate = Associate::find($assoc);
        
        if ( ! $associate) {
            return $this->respondNotFound('Associate does not exist');
        }
        
        return $this->respond([
            'associate' => $this->associateTransformer->transform($associate->toArray())
        ]);
        
    }

This is what I want to do

public function show(Associate $associate)    
    { 
        return $this->respond([
            'associate' => $this->associateTransformer->transform($associate->toArray())
        ]);
        
    }

and if an associate is not found

return $this->respondNotFound('Associate does not exist');

18th December, 2017

shaqaruden started a new conversation API Route Model Binding | Exception Handling • 4 weeks ago

How do I handle exceptions from Route Model Binding? I am building an API and I don't want an exception to be thrown when the record passed is not found I want to send a JSON response

15th December, 2017

shaqaruden left a reply on JSON Request Validation • 1 month ago

I am not doing authentication at the moment and yes I have the application/json header

14th December, 2017

shaqaruden started a new conversation JSON Request Validation • 1 month ago

I am using Postman to test my API.

When validating request data sent from Postman I get redirected to the home page if validation fails.

shaqaruden left a reply on JSON API | POST\PATCH Request • 1 month ago

???

shaqaruden left a reply on JSON API | POST\PATCH Request • 1 month ago

The function is being called but the json response is not being delivered

shaqaruden left a reply on Postman Patch Request • 1 month ago

The route is in API.php

shaqaruden left a reply on Postman Patch Request • 1 month ago

I know what to do for a website but I was just thinking if I specified the content type to be Json in postman a simple put or patch request would work.

13th December, 2017

shaqaruden started a new conversation Postman Patch Request • 1 month ago

Using Postman my application does not respond to a PATCH request. I have to send a POST request with the _method = PATCH field.

Why is this?

shaqaruden started a new conversation JSON API | POST\PATCH Request • 1 month ago

I am building a small JSON API and I am having issues with getting a JSON back from a PATCH request(POST Request with _method 'PATCH' field). The status code does not change to whatever i set it to and the there is no message or associate objects returned. This also applies to my POST

I am using a restful controller and following the practices shown in the Incremental API Course.

Here is the method that is called when an patch request is sent.

public function update($assoc, Request $request)
    {

        //Associate Stuff
        
        $this->respondUpdated('Associate successfully updated!', $associate);
    }

Here is the respondUpdated method

protected function respondUpdated($message, $associate) {
        return $this->setStatusCode(IlluminateResponse::HTTP_OK)->respond([
            'message' => $message,
            'associate' => $this->associateTransformer->transform($associate->toArray())
        ]);
    }
Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.