Guest User

Untitled

a guest
Dec 19th, 2017
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. axios({
  2. url: 'https://api:key-someapikey@api.mailgun.net/v3/somesandboxdomain1c.mailgun.org/messages',
  3. method: 'post',
  4. username: 'api',
  5. password: 'key-somekey',
  6. data: {
  7. from: "Excited User <mailgun@some.example.org>",
  8. to: "myemail@gmail.com",
  9. subject: "Hello from react app",
  10. text: "Testing some Mailgun awesomness!"
  11. },
  12. headers: {
  13. "Content-Type": "application/x-www-form-urlencoded",
  14. 'Authorization': `Basic ${window.btoa('api:key-someapikey')}`
  15. }
  16. })
  17. .then(function (response) {
  18. console.log(response);
  19. })
  20. .catch(function (error) {
  21. console.log(error);
  22. });
  23.  
  24. XMLHttpRequest cannot load https://api.mailgun.net/v3/somesandbox.mailgun.org. Request header field Authorization is not allowed by Access-Control-Allow-Headers in preflight response.
  25.  
  26. axios({
  27. method: 'post',
  28. url: `${mailgun.baseUrl}/${mailgun.domain}/messages`,
  29. auth: {
  30. username: 'api',
  31. password: mailgun.apiKey
  32. },
  33. params: {
  34. from: 'Awesome Development Team <noreply@yourdomain.com>',
  35. to: 'testing@example.com',
  36. subject: 'Hello',
  37. text: 'Welcome to the team!'
  38. }
  39. }).then(
  40. response => {
  41. console.log(response)
  42. },
  43. reject => {
  44. console.log(reject)
  45. }
  46. )
Add Comment
Please, Sign In to add comment