서버 측 Post 요청 중포 기지 기능이 반응하는 양식 작업

0

질문

때 나는 버튼을 클릭 프론트 엔드에,나는 감독이 localhost/만들기-계정 호스팅지만 렌더링할 수 없습니다"게시물". 그러나 우편 배달부를 보여줍 끝점이 잘 작동합니다.

이 무엇인지 확실하지 않고 여기에.

백엔드에서 끝점 중포 기지 기능 폴더

app.post("/create-account-hosted", async (req, res) => {
  try {
  var account = await stripe.accounts.create({
    type: "custom",
    requested_capabilities: ["card_payments", "transfers"],
    business_type: 'company',
    
  })

  var accountLink = await stripe.accountLinks.create({
    account: account.id,
    success_url: "https://example.com",
    failure_url: "https://example.com",
    type: "custom_account_verification", 
    collect: "eventually_due",
  });
} catch (err) {
  console.log(err);
  res.status(400);
  res.send({ error: err });
  return;
}

res.send(accountLink.url)

프런트 엔드 코드 형태로 게시물에 대한 요청을 서버 측의 리다이렉션.

<div className="beASeller">
                    <form
                        type="submit"
                        action="/create-account-hosted"
                        method="POST"
                        class="stripe-connect white"
                    >
                        <button> Seller Signup</button>
                    </form>
                </div>
2
1

이후 우편 배달이었를 쿼리하는 중포 기지 기능을 자체가 예: https://uscentral1.myfunction.cloudfunctions.net/create-account-hosted에,나는 할 필요가 동일한 내 프런트 엔드 코드입니다.

<div className="beASeller">
         <button                        
         action="https://uscentral1.myfunction.cloudfunctions.net/create-account-hosted/"
         class="stripe-connect white"
         >
         </button>
</div>
2021-11-24 07:29:43
1

을 사용할 수도 있습 HTTP 클라이언트입니다. 이 경우,우리는 당 사용 Axios.

의 무리가 있습니다 추가 옵션을 활용할 수 있습니다 할 때 사용하여 요청 Axios지만,여기에는 가장 일반적인 사람:

  • base 을 -지정하는 경우 기본 URL,그 앞에 모든 상대 URL 을 사용할.
  • 헤더의 -객체의 키/값 쌍으로 전송할 수 있습니다.
  • params -체의 키/값 쌍으로는 직렬화하고 추가로 URL 에 query string.
  • responseType -을 경우 응답을 받아야 하는데에 다른 형식으로 JSON,이 속성을 설정할 수 있습을 arrayBuffer,blob,문서,텍스트 또는 스트림입니다.
  • 인증:전달하는 개체와 사용자 이름과 암호 필드에 사용할 이들에 대한 자격 증명하는 HTTP Basic auth 에서 요청을 합니다.

참조할 수도 있습니다 여기설정에 대해 Axios 프로젝트에서.

설치 후,사용할 수 있습니다 Axios. 참조하시기 바랍 아래 예제 코드:

import axios from 'axios';

axios.post('https://uscentral1.myfunction.cloudfunctions.net/create-account-hosted', {"body":data}, {
    headers: {
    'Content-Type': 'application/json'
    'Authorization': 'Bearer ' + token
    }
  }
)

또한 확인하시기 바랍 2 단계-4 시하는 경우 그것은 또한 도움이 됩니다.

2021-11-24 10:14:31

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................