チキン食品プロジェクト8日目

1492 ワード

今日やったこと

  • データとトークンを受け取り、mypageにuserNameを入力
  • うなずく

  • commons.他のscssファイルでscssを使用する内容は、scssファイルでよく見られます.scssファイルをインポートする必要があります.
  • aタグをdivタグに変換してonclickイベントを付与する方法も用いられる.
    ::aタグ発生ページリフレッシュ
    :::linkラベルとaラベル、onclickイベントの違いは何ですか?
  • 今日は初めてToken
  • 注意事項
    1)URLチェック
    :: http://:: :8000
  •   submitUserInfo = e => {
        // e.preventDefault();
        fetch('http://10.58.1.207:8000/members/agreement', {
          method: 'POST',
          body: JSON.stringify(this.state.userInfo),
        })
          .then(response => response.json())
          .then(result => console.log('결과: ', result));
      };
    ログイン成功時にトークンを受信しlocalStorageに保存するコード
    fetch('LOGIN_API', {
      method: 'POST',
      body: JSON.stringify({
        email: this.state.email,
        password: this.state.password,
      })
    })
      .then(res => res.json())
      .then(res => {
        if (res.message === 'SUCCESS') {
          localStorage.setItem('token', res.access_token);
          this.props.history.push('/main');
        } else {
          alert('다시 입력해주세요!')
        }
      })
    保存されたタグの使用方法
    fetch('UPDATE_CART_API', {
      method: 'POST',
      headers: {
        Authorization: localStorage.getItem('token'),
      }
      body: JSON.stringify({
        cartId: this.state.cartId,  
      })
    })
    .then()
    .then()