简体   繁体   English

解析400(错误请求)

[英]Parse 400 (Bad Request)

I have looked into the various ways of sending an email through a form on a static site. 我研究了通过静态站点上的表单发送电子邮件的各种方法。 This way here @ https://sendgrid.com/blog/send-email-static-websites-using-parse/ looked the best for me! 这样,这里@ https://sendgrid.com/blog/send-email-static-websites-using-parse/最适合我! Loved the tutorial..Good stuff from Martyn Daviesonon how to do deploy cloud code and use the javascript api from parse. 很喜欢这个教程。MartynDaviesonon的好东西如何部署云代码并使用解析中的javascript API。 Thanks for sharing Martyn :) 感谢您分享Martyn :)

However I have ran into an issue with actually getting this to work properly...I really want to use this method but it just needs a little fixing. 但是我在实际使它正常工作时遇到了一个问题...我真的很想使用这种方法,但是它只需要一点点修复即可。

Currently I am having this error pop up in my console. 目前,我的控制台中弹出此错误。 It's a 400 bad request.. When I click on the link to emailer.js:28 it takes to to this in my code. 这是一个400错误的请求。.当我单击emailer.js:28的链接时,这在我的代码中得到了解决。 This is where the error is seems to be happening in emailer.js 这似乎是在emailer.js中发生错误的地方

在此处输入图片说明

  error: function(object, error) {
    console.log(error);
    $('#response').html('Error! Email not sent!').addClass('error').fadeIn('fast');
  }

Lastly I don't have an email set up for my domain name. 最后,我没有为域名设置电子邮件。 This is because I am still building this site on gh-pages. 这是因为我仍在gh-pages上构建此站点。 The email that I am using while I test this function is my gmail email. 我在测试此功能时使用的电子邮件是我的gmail电子邮件。 Is this also a potential issue? 这也是潜在的问题吗? When I actually deploy this site I will use a domain name email. 当我实际部署该站点时,我将使用域名电子邮件。

First things first. 首先是第一件事。

You really should remove your Parse.com credentials from your email.js file since from the moment you posted access to that file, anyone can use your account for pretty much any unsavory thing they fancy . 实际上,您应该从email.js文件中删除Parse.com凭据,因为从发布对该文件的访问权限的那一刻起, 任何人都可以使用您的帐户来处理他们喜欢的任何不愉快的事情 Just saying. 只是说。

Next, your email.js file appears to call a server-side/cloud function called sendEmail via parse.com's REST API but you do not appear to define that function anywhere. 接下来,您的email.js文件似乎通过parse.com的REST API调用了名为sendEmail的服务器端/云函数,但您似乎没有在任何地方定义该函数。 At least, it's not in your email.js file. 至少,它不在您的email.js文件中。 Did you already do this? 你已经做到了吗? Did you apply for the proper credentials from sendgrid to allow you access to their API? 您是否从sendgrid申请了适当的凭据以允许您访问其API?

The article you mention as your inspiration defines a sendEmail() function that calls the REST API at sendgrid to actually deliver email messages. 您作为灵感提到的文章定义了sendEmail()函数,该函数在sendgrid调用REST API来实际传递电子邮件。 This function is then deployed to the cloud server using the parse.com's Parse.cloud.define() function. 然后,使用parse.com的Parse.cloud.define()函数将该功能部署到云服务器。

If you haven't done this, then there is no function for you to call via https://api.parse.com/1/functions/sendEmail . 如果您尚未执行此操作,则没有可通过https://api.parse.com/1/functions/sendEmail调用的函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM