cli: switch to axios

This commit is contained in:
Thomas Hobson 2021-03-13 16:44:33 +13:00
parent a1536ffe56
commit 5a05537a7f
No known key found for this signature in database
GPG key ID: 9F1FD9D87950DB6F
6 changed files with 48 additions and 46 deletions

View file

@ -1,4 +1,4 @@
const fetch = require('node-fetch');
//const fetch = require('node-fetch');
const fs = require('fs');
const path = require('path');
const chalk = require('chalk');
@ -59,14 +59,8 @@ exports.handler = async function(argv){
run_timeout: argv.rt
};
const response = await fetch(argv['piston-url'] + '/jobs', {
method: 'post',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(request)
})
.then(res=>res.json())
.then(res=>{if(res.data)return res.data; throw new Error(res.message)})
.catch(x=>x);
let response = await argv.axios.post('/jobs', request);
response = response.data
function step(name, ctx){
console.log(chalk.bold(`== ${name} ==`))