ToolJet/docs/versioned_docs/version-2.68.0/how-to/use-axios.md
Aman Regu bdfe3270e2
[docs]: v2.68.0-Beta (#10755)
* docs: jira

* docs: formatting + Client Credentials grant type

* docs: connection string pgsql

* docs: parameterized queries mysql

* docs: parameterized queries in PostgreSQL

* docs: update mysql example

* docs: TJDB sql editor

* docs: add metadata to REST API

* docs: add, update  postgresql media

* docs: add metadata to graphql

* docs: update parameterized queries

* docs: add parameterized queries for mssql

* docs: add SSL Cert to mysql

* docs: TJDB SQL restricted commands

* docs: update JIRA token location

* docs: update delete issue example

* docs: update find user by query example

* docs: remove session id from get assignable users

* docs: use correct image for get issues for board

* docs: update create issue example

* docs: update delete issue media

* docs: update assignable users media

* docs: update examples

* docs: update key desc

* docs: v2.68.0-Beta
2024-09-13 19:23:19 +05:30

68 lines
No EOL
2 KiB
Markdown

---
id: use-axios-in-runjs
title: Use Axios in RunJS
---
<div style={{paddingBottom:'24px'}}>
ToolJet supports three libraries: **Moment.js**, **Lodash**, and **Axios**. This guide focuses on using the Axios library with RunJS queries. **[Axios](https://axios-http.com/docs/intro)** is a promise-based HTTP client for making requests to your own or external servers. It supports various request types like `GET`, `POST`, `PUT/PATCH`, and `DELETE`.
</div>
<div style={{paddingTop:'24px', paddingBottom:'24px'}}>
## GET Requests
We'll use **[JSONPlaceholder](https://jsonplaceholder.typicode.com/)**, a free API, to demonstrate GET and PUT requests.
- Create a RunJS query and paste the code below:
```javascript
var url = "https://jsonplaceholder.typicode.com/users/1";
var data = (await axios.get(url)).data;
return data
```
*This code sets up a URL variable, makes a GET request to the API, and returns the data. Preview the query to see the API's response.*
<div style={{textAlign: 'center'}}>
<img style={{ border:'0', marginBottom:'15px' }} className="screenshot-full" src="/img/how-to/use-axios/get.png" alt="Use Axios in RunJS"/>
</div>
</div>
<div style={{paddingTop:'24px', paddingBottom:'24px'}}>
## POST Requests
- Create a RunJS query and paste the code below:
```javascript
var url = "https://jsonplaceholder.typicode.com/users";
var data = axios.post(url,{
id: 11,
name: "Shubhendra",
username: "camelcaseguy",
email: "shubhendra@tooljet.com",})
return data
```
This POST request sends user details to the server. The server's response, as shown below, includes **Status: 201** indicating successful resource creation.
<div style={{textAlign: 'center'}}>
<img className="screenshot-full" src="/img/how-to/use-axios/post.png" alt="Use Axios in RunJS"/>
</div>
To see Axios in action in a project, check out this tutorial:
**[Build GitHub star history tracker](https://blog.tooljet.com/build-github-stars-history-app-in-5-minutes-using-low-code/)**.
</div>