繁体   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