Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
run({ country, zipcode }) {
this.unblock();
switch (country) {
case "BR":
const match = zipcode.match(/\d+/gi);
if (match && match.length) {
const code = match.join("");
if (code.length == 8) {
return Promise.await(cep(code));
}
}
return {};
default:
let res;
let data = {};
try {
res = Promise.await(
axios.get(`http://api.zippopotam.us/${country}/${zipcode}`)
);
data = res.data;
} catch (e) {
return data;
} finally {
if (data && data.places && data.places.length) {
return {