RunKit + npm: got

node v10.24.1
endpointsharetweet
const got = require("got"); const ISS = "http://api.open-notify.org/iss-now.json"; let coger=function(id) { if (!id) { return Promise.reject(new Error("Introduzca una id")); } return got(ISS,{ json: true }).then((res)=>{ let resultado = res.body; if(resultado.error) { return Promise.reject(new Error(res.body.error)); } resultado.id = id; return resultado; }); }; // sin ID coger().then((res)=>{ console.log('Resultado: ', res); }).catch((err)=>{ console.log('Error: ',err); }); // con ID coger(25).then((res)=>{ console.log('Resultado: ', res); }).catch((err)=>{ console.log('Error: ',err); });
Created from: https://npm.runkit.com/got
Loading…