Hi Readers, In this blog, I am going to explore, HTTP methods in K6.
Basically, HTTP methods are also called HTTP verbs and CRUD operations because it is a set of requests which perform the desired actions like get, put, post, delete and so on.
CRUD stands for Create, Read, Update and Delete. These are four primitive database operations that map well to the HTTP verbs most frequently used in Rest Services.
HTTP request in K6-
In this, http module contains functionality like put() , get(), post(), delete(), head() etc.
GET() – GET is used to request data from a specified resource. Get requests to remain in the browser history.
- Install the K6 in your system- https://k6.io/docs/getting-started/installation/
- Install any IDE- Visual Studio-https://dzone.com/articles/install-visual-studio-code-on-ubuntu-1804
Writing first Script in K6 with get method
k6/HTTP into the js file- import http from k6/http.
VUs(Virtual Users):-A number of users execute as many iterations as possible for a specified amount of time.
Sleep:- Sleep doesn’t impact the test duration. It will impact how quickly the Virtual users can complete iterations.
Run this file in the terminal- k6 run http_get.js(filename)
POST() – POST is used to send data to a server to create a resource.
create one file with http_post.js
PUT() – PUT is used to send data to a server to create/update a resource.
create one file with http_put.js
DELETE() – The DELETE method deletes the specified resource.
create one file with http_delete.js
I hope you enjoyed it and it helped you!! stay connected for more future blogs.