ロゴ
  • about
  • Contact
    カテゴリ

    コーディング

    時間undefined/undefined/undefined

    next.js .env.localについて

    <p>Next.jsバージョン9.4以降から、環境変数の取り扱いが変更になっているようです。<br>サーバー側でに渡す環境変数は、.env.localで設定すれば良くて、<br>クライアント側からアクセスしたい環境変数は、.env.localに記載後、<br>next.config.jsで再度、設定するといい<br><br>.env.local</p><pre><code>API_KEY=XXXXXXXX END_POINT=XXXXXXX SLACK_WEBHOOK_URL=XXXXXXXXX</code></pre><p><br>next.config.js</p><pre><code>module.exports = {&nbsp; &nbsp; env:{&nbsp; &nbsp; &nbsp; SLACK_WEBHOOK_URL:process.env.SLACK_WEBHOOK_URL &nbsp; } };</code></pre><p><br><br>あれ、これでもconsoleから見えちゃう。。。</p>

    カテゴリ

    コーディング

    時間undefined/undefined/undefined

    firebase cloud functions 無料プランについて

    <p>firebaseの無料プランで学習用にcloud functionの設定をしている際、</p><pre><code>firebase deploy</code></pre><p>すると、</p><pre><code>Error: Cloud Functions deployment requires the pay-as-you-go (Blaze) billing plan. To upgrade your project, visit the following URL:</code></pre><p><br>と有料プランにしないと、使えないよと言われます。<br>対策としては、<br>functionsフォルダのpackage.jsonの下記部分を</p><pre><code>&nbsp;"engines": { &nbsp;&nbsp;"node": "10" &nbsp;},</code></pre><p><br></p><pre><code>&nbsp;"engines": { &nbsp;"node": "8" &nbsp;},</code></pre><p><br>に変更することで、2021-03-15までは使えるようです。</p>

    カテゴリ

    コーディング

    時間undefined/undefined/undefined

    クロージャについて

    <h1 id="h5c469d82e8">・クロージャー</h1><p>定義・・・レキシカルスコープの変数を関数が使用している状態<br><br><br></p><h3 id="h20feb2cff2">ケース01・・・プライベート変数の定義</h3><p>グローバルに定義するとどこからでも参照できるため、関数スコープ内に変数を定義<br><br>・グローバルに定義</p><pre><code>let num = 0 console.log("Global", num); increment() increment() increment() function increment() { &nbsp; &nbsp; num = num + 1 &nbsp; &nbsp; console.log(num); }</code></pre><p><br>・クロージャー使用</p><pre><code>function incrementFactory() { &nbsp; &nbsp; let num = 0 &nbsp; &nbsp; function increment() { &nbsp; &nbsp; &nbsp; &nbsp; num = num + 1 &nbsp; &nbsp; &nbsp; &nbsp; console.log(num); &nbsp; &nbsp; } &nbsp; &nbsp; return increment } const increment = incrementFactory() increment() increment() increment()</code></pre><p><br></p><h3 id="hab1d653a0d">ケース02・・・動的関数</h3><pre><code>function addNumberFactory(num) { &nbsp; &nbsp; function addNumber(value) { &nbsp; &nbsp; &nbsp; &nbsp; return num + value; &nbsp; &nbsp; } &nbsp; &nbsp; return addNumber; } const add5 = addNumberFactory(5); const result = add5(5); const result = add5(10);</code></pre><p><br>変数numを固定した関数を生成できます<br><br><br></p>

screew

カテゴリ

  • Hasura
  • WordPress
  • デザイン
  • コーディング
  • About
  • Contact
  • カテゴリ

© All rights reserved