mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Merge pull request #626 from p0tat0chip/docs
Add Instructions to run generated code in JS(axios, fetch) and Go
This commit is contained in:
@ -268,15 +268,100 @@ Here are the detailed instructions for running the generated API Dash code in **
|
|||||||
|
|
||||||
## Go (net/http)
|
## 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 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)
|
## 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>Axios Example</title>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
// Paste your API Dash 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)
|
## JavaScript (fetch)
|
||||||
|
|
||||||
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>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script>
|
||||||
|
// Paste your API Dash 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.
|
||||||
|
|
||||||
## node.js (JavaScript, axios)
|
## node.js (JavaScript, axios)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user