Instructions to run generated code in JS(axios, fetch) and Go

This commit is contained in:
Mayank Singh
2025-02-28 11:09:41 +05:30
committed by GitHub
parent 5245052d6c
commit f8bea010a3

View File

@@ -268,15 +268,70 @@ Here are the detailed instructions for running the generated API Dash code in **
## Go (net/http)
TODO
### 1. Install Go compiler
- Windows and MacOS: check out the [official source](https://go.dev/doc/install)
- Linux: Install from your distro's package manager.
Verify the if go is installed:
```bash
go version
```
### 2. Create a project
```bash
go mod init example.com/api
```
### 3. Run the generated code
- Paste the generated code into `main.go`.
- Build and run by `go run main.go`.
## JavaScript (axios)
TODO
The generated api code can be run in browser by using the code in an html file as demonstrated below:
### 1. Create the html file with generated code
Create a new file `index.html`
```html
<!DOCTYPE html>
<html>
<head>
<title>Fetch Example</title>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
</head>
<body>
<script>
// Paste your APIDash generated code here !!
</script>
</body>
</html>
```
Make sure to paste the generated js code from api dash under the
`<script>` tag.
### 2. Test with Browser Developer Tools
Open the `index.html` file in a modern browser and open devtools.
- **Chrome**: Right-click the page and select "Inspect" or press Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (macOS).
- **Firefox**: Right-click the page and select "Inspect Element" or press Ctrl+Shift+I (Windows/Linux) or Cmd+Option+I (macOS).
- **Edge**: Right-click the page and select "Inspect" or press F12 or Ctrl+Shift+I.
Navigate to network tab and refresh the page to see the requests and network activity.
## JavaScript (fetch)
TODO
Same instructions as [JavaScript (axios)](#javascript-axios) and delete the following line from the html code.
```html
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
```
## node.js (JavaScript, axios)