How to optimize and simplify code using ES6

how to optimize readability and simplification, here are two pieces of code:

the first paragraph of code

const defaultObj = {
    content: {
    },
};
defaultObj.content.address = res.after.temporary.address.data;
defaultObj.content.people = res.after.temporary.people.data;
defaultObj.content.stroke = res.after.temporary.stroke.data;
defaultObj.content.take = res.after.temporary.take.data;

second paragraph of code

switch (key) {
    case "people": {
        this.$router.push({
            path: "/select-person",
        });
        break;
    }
    case "address": {
        this.$router.push({
            path: "/select-address",
        });
        break;
    }
    case "take": {
        this.$router.push({
            path: "/take-address",
        });
        break;
    }
    case "stroke": {
    ...
Feb.25,2022

one

const defaultObj = {
    content: {}
};
let nameArr = ['address', 'people', 'stroke', 'take'];

nameArr.forEach(v => {
    defaultObj.content[v] = res.after.temporary[v].data;
});

two

this.$router.push({
    path: `/select-${key}`,
});

Object.keys(res.after.temporary).map(k=>{
  defaultObj.content[k] = res.after.temporary[k].data
})

the second one turns key and path into {}

.
const obj = {
    content: {}
};

let {address, people, stroke, take} = res.after.temporary

obj.content = {
    address: address.data,
    people: people.data,
    stroke: stroke.data,
    take: take.data
}
let routes = {
    'people': '/select-person',
    'address': '/select-address',
    'take': '/take-address'
}

function linkTo(key) {
    key && this.$router.push(routes[key])
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b35c23-2bfc4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b35c23-2bfc4.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?