loading...

Experience in this week 20200429

adachi_koichi profile image Koichi Adachi ・2 min read

Experience in this week

fetch() on Nuxt 2.12.x

treat 'this' object in fetch() at Nuxt 2.12.x
In this advantage, divide processing Statefull ViewModel or Data Access Layer to other .ts file.

sequence

  1. $router.replace(newURL)
  2. fetch()
  3. updateListFromQuery()
  4. repository.fetch()
  5. update this.$data.list
  6. -> refresh screen
@Component({
  watch: {
    '$route.query': '$fetch'
  }
})
export default class HogeListVueImpl extends Vue implements HogeListVue {
  public async fetch() {
    await this.updateListFromQuery()
  }

  private async updateListFromQuery() {
    this.$data.list = await this.repository.get(this.$route.query)
  }
}
export default class Header extends Vue {
  public async onClickChangeUserButton() {
    const url = this.createReplaceURL(this.$route.path, this.$route.query, this.$data.userIndex)
    this.$router.replace(url)
  }
}

@nuxtjs/proxy

changing to route implicitly.

.ex

BASE_URL=http://localhost:9001
PROXY_TARGET=http://localhost:9001
AXIOS_PREFIX=/api
  axios: {
    baseURL: process.env.BASE_URL,
    credentials: true,
    prefix: process.env.AXIOS_PREFIX,
    proxy: process.env.ENV === 'local'
  },
  proxy: {
    [<string>process.env.AXIOS_PREFIX]: {
      target: process.env.PROXY_TARGET,
      pathRewrite: { '^/api': '/' }
    }
  },
"@nuxtjs/axios": "^5.3.6",
"@nuxtjs/proxy": "^1.3.3",

nuxt-proxy

async hoge(){
    await window.$nuxt.$axios
      .get('v1/login')
      .then((response) => {
}

change url
localhost:8000/v1/login
to
localhost:9001/api/v1/login

  1. add 'api' by AXIOS_PREFIX
  2. change to localhost:9001 by @nuxtjs/proxy

on Chrome inspector
localhost:9001/api/v1/login
->
localhost:8000/api/v1/login

Cant intersept other Proxy Software(ex.Charles)

iOS Build failed by CocoaPods

checkout other branch branch, frequently fail to build.
because cause mismatch libraries integration.

how to fix this issue, have to clear any caches and rebuild Pods

rm Podfile.lock

rm -rf Pods
rm -rf ~/.cocoapods
rm -rf xxxxxxxx.xcworkspace
pod cache clean --all
rm -rf ~/Library/Developer/Xcode/DerivedData
rm -rf ~/Library/Caches/AppCode2019.3
rm -rf ~/Library/Caches/CocoaPods

iOS cant use REPL boundary Pods library and code

plugin 'cocoapods-binary'
all_binary!
pod 'IBAnimatable', binary: false

'cocoapods-binary' plugin serve prebuild libraries
want to use REPL for librarie's objects,
disable this plugin and build local machine.

Discussion

pic
Editor guide