34 lines
596 B
JavaScript
34 lines
596 B
JavaScript
// Simple test to create test user
|
|
const https = require('http');
|
|
|
|
const data = JSON.stringify({
|
|
name: '测试用户',
|
|
email: 'test@example.com'
|
|
});
|
|
|
|
const options = {
|
|
hostname: 'localhost',
|
|
port: 3001,
|
|
path: '/api/users',
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Content-Length': data.length
|
|
}
|
|
};
|
|
|
|
const req = https.request(options, (res) => {
|
|
console.log(`Status Code: ${res.statusCode}`);
|
|
|
|
res.on('data', (d) => {
|
|
process.stdout.write(d);
|
|
});
|
|
});
|
|
|
|
req.on('error', (error) => {
|
|
console.error(error);
|
|
});
|
|
|
|
req.write(data);
|
|
req.end();
|