code update recorded at: 25/06/25 11:47:51
This commit is contained in:
commit
9e44489670
|
|
@ -0,0 +1,31 @@
|
||||||
|
const handler = async () => {
|
||||||
|
// Importing necessary modules
|
||||||
|
import { createServer } from 'http';
|
||||||
|
|
||||||
|
// Creating a function to make the HTTP request
|
||||||
|
const makeHttpRequest = () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const req = http.request('http://169.254.169.254', (res) => {
|
||||||
|
let data = '';
|
||||||
|
res.on('data', (chunk) => {
|
||||||
|
data += chunk;
|
||||||
|
});
|
||||||
|
res.on('end', () => {
|
||||||
|
resolve(data);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
req.on('error', (err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
req.end();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Making the HTTP request and returning the result
|
||||||
|
const result = await makeHttpRequest();
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
return error.message;
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue
Block a user