generated from fahricansecer/boilerplate-be
This commit is contained in:
23
test-fetch.cjs
Normal file
23
test-fetch.cjs
Normal file
@@ -0,0 +1,23 @@
|
||||
const http = require('http');
|
||||
async function test() {
|
||||
const req = http.request({
|
||||
hostname: 'localhost',
|
||||
port: 3000,
|
||||
path: '/api/projects',
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
}, (res) => {
|
||||
let rawData = '';
|
||||
res.on('data', (chunk) => rawData += chunk);
|
||||
res.on('end', () => {
|
||||
console.log('Status code:', res.statusCode);
|
||||
console.log('Raw data length:', rawData.length);
|
||||
console.log('Raw data start:', rawData.slice(0, 200));
|
||||
});
|
||||
});
|
||||
req.on('error', (e) => console.error(`problem with request: ${e.message}`));
|
||||
req.end();
|
||||
}
|
||||
test();
|
||||
Reference in New Issue
Block a user