簡體   English   中英

不使用端點發送表單

[英]Send a form without using endpoint

為了使用這個 npm 包,我需要一個 api 端點,但是如果我想用 smtp 發送它呢?

我沒有這種包的經驗,所以我會感謝你的幫助!

包是: https : //www.npmjs.com/package/@betahuhn/feedback-js

到目前為止我的實際代碼:

const options = {
      id: 'feedback', // id to identify the form on the backend
      endpoint: baseUrl, // enpoint of your backend to handle the submission
      emailField: true, // show email input field, default: false
      btnTitle: 'Feedback', // title of button
      title: 'Company Feedback', // text at the top
      contactText: 'Or send an email!', // text for other contact option
      contactLink: Contact, // link for other contact option
      typeMessage: 'What feedback do you have?', // message for selecting feedback type
      success: 'Thanks! 👊', // message displayed on successfull submission
      failedTitle: 'Oops, an error ocurred!', // title displayed on error
      failedMessage: 'Please try again. If this keeps happening, try to send an email instead.', // default error message if backend doesn't return one
      position: 'right', // position of button left/right
      primary: 'rgb(53, 222, 118)', // primary color
      background: '#fff', // background color
      color: '#000' // font color
    }
    console.log(Contact);
    console.log(baseUrl);
      new Feedback(options).attach();

  })

我怎樣才能以最簡單的方式發送它?

您需要一個端點,因為代碼必須處理您的表單,HTML 表單只是一個靜態的東西,它只負責將數據傳遞給某個腳本。

如果您不想花時間編寫 API 端點,您可以嘗試使用formcarry等表單端點服務,它允許您在沒有任何后端代碼的情況下收集提交

如果你想編寫自己的端點,那么你可以關注這篇詳細的博客文章

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM