Lessons: 34Length: 2.5 hours

Next lesson playing in 5 seconds

Cancel
  • Overview
  • Transcript

4.11 HTTP Requests Within Sublime

Let's say I'm working in a framework where I can specify the routes that I want to respond to. Normally, you will set your route, you will respond accordingly, and then maybe you'll view that in the browser to test it. And that certainly works fine enough. But, let me show you a plugin that makes this a little bit easier for quick checks. We will install it through package control, install, and it's called HTTP requester. So now let's try this out. Why don't we do something like this? When the user requests the home page, we're going to grab all of the users. Don't worry about the syntax here, that really has very little to do with this lesson. So we're going to grab the users, and why don't we do response. We're going to add this as eloquent, and I'll send in the users. So now, let's take a look at the manual way of testing to see what this does for us. We run it, and sure enough, we get this little bit of JSON with a couple rows from the users table. But now, I'll show you how to do this directly from the editor. We've installed that Http Requester plug-in, so now check this out. I can add a URL. We'll do Laravel.dev and now I will run this through the plug-in by selecting it and clicking on the Mac, CMD+Option+R. It will immediately create a new tab and show you what was received in response. By the way, if you are a Windows user, this would be CTRL+ALT+R. So let's try another one. Why don't I duplicate this? And now we will say when we wanna grab users/ and then maybe a specific ID. We'll fetch that ID and then we will find the one user that has that specific ID. And we will return once again response eloquent user. So now if you're in the middle of working you don't have to open up the browser. Just quickly run larevel.dev users one and let's run that through the plugin CMD+Option+R. And yep we get a two hundred response and we did return the user with a ninety of one. Now as I understand things at the time of this writing only the get verb is supported. But I believe support for the others is on it's way. Finally, if you can't remember what that shortcut is, it's also available in the right-click menu. So I right-click, Http Requester, and now we do get that result. So if we try to request something that doesn't exist in the edit, we haven't written that one just yet. We run it, and now we do get 404. So that's a helpful reminder when you're in the middle of working and you don't feel like switching over to your browser to try out a specific route.

Back to the top