Skip to content

Commit e0de4a2

Browse files
Update instructions_to_run_generated_code.md
Step-by-step guide on how to run API requests using different libraries and methods in JavaScript and Node.js using fetch and axios on major platforms like macOS, Linux, and Windows.
1 parent 6fcc698 commit e0de4a2

File tree

1 file changed

+145
-4
lines changed

1 file changed

+145
-4
lines changed

doc/user_guide/instructions_to_run_generated_code.md

Lines changed: 145 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,160 @@ TODO
197197

198198
## JavaScript (axios)
199199

200-
TODO
200+
`Axios` is a promise-based HTTP client for the browser and Node.js.
201+
### 1. Installation:
202+
-Ensure Node.js and npm are installed. Verify by running:
203+
204+
```bash
205+
node --version
206+
npm --version
207+
```
208+
-If not, download from Node.js **[Official Website]((https://nodejs.org/en))**.
209+
210+
-Initialize a new Node.js project:
211+
212+
```bash
213+
npm init -y
214+
```
215+
216+
-Install Axios:
217+
218+
```bash
219+
npm install axios
220+
```
221+
222+
### 2. Running the Generated Code::
223+
-Create a new JavaScript file (`e.g., app.js`).
224+
-Copy and paste the generated code into this file.
225+
-Open a terminal and navigate to the project directory.
226+
-Run the script:
227+
228+
```bash
229+
node app.js
230+
```
201231

202232
## JavaScript (fetch)
203233

204-
TODO
234+
macOS, Linux, and Windows:
235+
### 1. Node.js:
236+
-Follow the same steps as above to install Node.js.
237+
238+
### 2. Set Up a New Project:
239+
-Create a new project folder and navigate into it
240+
```bash
241+
mkdir fetch-example
242+
cd fetch-example
243+
```
244+
-Initialize the project:
245+
```bash
246+
npm init -y
247+
```
248+
249+
### 3. Ensure Fetch API Support:
250+
-Starting with Node.js 18, the Fetch API is built-in. Verify the version:
251+
252+
```bash
253+
node --version
254+
```
255+
256+
-If you’re using an earlier version, install a Fetch polyfill:
257+
258+
```bash
259+
npm install node-fetch
260+
```
261+
262+
### 4. Create and Run the Code:
263+
-Save the generated code in a file, e.g., fetch_example.js.
264+
-If using node-fetch, add this line at the top of your file:
265+
266+
```bash
267+
const fetch = require('node-fetch');
268+
```
269+
270+
-Run the code:
271+
272+
```bash
273+
node fetch_example.js
274+
```
205275

206276
## node.js (JavaScript, axios)
207277

208-
TODO
278+
macOS, Linux, and Windows:
279+
### 1.Install Node.js:
280+
-Follow the installation steps above.
281+
282+
### 2.Set Up a New Project:
283+
-Create a new project directory:
284+
285+
```bash
286+
mkdir node-axios-example
287+
cd node-axios-example
288+
```
289+
290+
-Initialize the project:
291+
292+
```bash
293+
npm init -y
294+
```
295+
296+
### 3.Install Axios:
297+
298+
-Install the Axios library:
299+
300+
```bash
301+
npm install axios
302+
```
303+
304+
### 4.Create and Run the Code:
305+
306+
-Save the generated code in a file(` e.g., app.js`).
307+
-Run the code:
308+
309+
```bash
310+
node app.js
311+
```
209312

210313
## node.js (JavaScript, fetch)
211314

212-
TODO
315+
macOS, Linux, and Windows:
316+
### 1. Install Node.js:
317+
-Follow the installation steps above.
318+
319+
### 2. Set Up a New Project:
320+
Create a project directory:
321+
322+
```bash
323+
mkdir node-fetch-example
324+
cd node-fetch-example
325+
```
326+
327+
### 3.Initialize the project:
328+
329+
```bash
330+
npm init -y
331+
```
332+
333+
### 4.Ensure Fetch API Support:
334+
-If using Node.js 18 or newer, the Fetch API is already built-in.
335+
-For older versions, install the `node-fetch` package:
336+
337+
```bash
338+
npm install node-fetch
339+
```
340+
341+
### 5.Create and Run the Code:
342+
-Save the generated code in a file( `e.g., app.js`).
343+
-If using `node-fetch`, add the following line to the top of the file:
344+
345+
```javascript
346+
const fetch = require('node-fetch');
347+
```
348+
349+
-Run the file:
350+
351+
```bash
352+
node app.js
353+
```
213354

214355
## Java (asynchttpclient)
215356

0 commit comments

Comments
 (0)