const http = require('http') const data = JSON.stringify({ cardId: 'rc_card_c6aebdfb-7330-43c1-b42c-a6a856a715f2' }) const req = http.request({ hostname: '127.0.0.1', port: 8976, path: '/api/mp_rep_clock/kits/rep_clock/sessions/start', method: 'POST', headers: { 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': Buffer.byteLength(data), 'Accept': 'application/json; charset=utf-8', 'X-Mp-Timeassistant': 'smoke_test_probe_xxx', } }, (res) => { let buf = '' res.on('data', c => buf += c) res.on('end', () => { console.log('HTTP', res.statusCode) console.log('BODY:', buf) try { const j = JSON.parse(buf) console.log('字段检查:') console.log(' ok =', j.ok) console.log(' error =', j.error) console.log(' conflictSessionId =', j.conflictSessionId) console.log(' conflict_session_id =', j.conflict_session_id) console.log(' expiresInMs =', j.expiresInMs, typeof j.expiresInMs) console.log(' expires_in_ms =', j.expires_in_ms, typeof j.expires_in_ms) } catch (e) { console.log('not json', e.message) } }) }) req.on('error', e => console.log('err:', e.message)) req.write(data) req.end()