gasilel.blogg.se

Just press record to fileapp
Just press record to fileapp












just press record to fileapp

Now, you should be getting "Routing Error", which is what we expected. So, after making sure that your server is indeed running, Hit Send again to try sending the request.

#Just press record to fileapp how to

Hit Send.Īre you getting "Could not get any response"? If so, that's because you haven't started the server yet! Do you remember how to start the server? Hint: $ rails s Let's input the URL localhost:3000/books with the HTTP request type set to POST. Even though you probably know that it won't work, it's still good to see what errors it will produce. Just click on "Skip this, go straight to the app".īefore we move on, we also need to go to app/controllers/application_controller.rb and comment out the line protect_from_forgery with: :exception.

just press record to fileapp

After installation, there's no need to sign up.

just press record to fileapp

To help us make a lot of different HTTP requests, we are going to use a tool called Postman. Normally when you put a URL in the browser's URL bar, it will only make a GET request. Now that we have the route defined, can we just try sending a request already? Sure! But, how do you send a POST request? Can you do it on a Chrome browser? Yes, but you need some other tools to help you. So, if you make a POST request to localhost:3000/books with the correct parameters, it should create new records in the book table in our database.įirst of all, we have to define a route first. We are going to create an API endpoint that accepts requests with POST method. There are 4 main types of requests: GET / POST / PUT / DELETE to get / create / update / delete information, respectively. Inside the controller, you can define how yu want to handle and process the request.įor example, we want to allow any person to create a book record through a URL. When a request is sent to your API, routes (that you have defined) will pass the request to corresponding controllers for handling. In this section, we are going to write a primitive API endpoint.














Just press record to fileapp