Guest User

Untitled

a guest
Dec 19th, 2017
395
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:[email protected]/v3/somesandboxdomain1c.mailgun.org/messages',
  3. method: 'post',
  4. username: 'api',
  5. password: 'key-somekey',
  6. data: {
  7. from: "Excited User <[email protected]>",
  8. subject: "Hello from react app",
  9. text: "Testing some Mailgun awesomness!"
  10. },
  11. headers: {
  12. "Content-Type": "application/x-www-form-urlencoded",
  13. 'Authorization': `Basic ${window.btoa('api:key-someapikey')}`
  14. }
  15. })
  16. .then(function (response) {
  17. console.log(response);
  18. })
  19. .catch(function (error) {
  20. console.log(error);
  21. });
  22.  
  23. 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.
  24.  
  25. axios({
  26. method: 'post',
  27. url: `${mailgun.baseUrl}/${mailgun.domain}/messages`,
  28. auth: {
  29. username: 'api',
  30. password: mailgun.apiKey
  31. },
  32. params: {
  33. from: 'Awesome Development Team <[email protected]>',
  34. subject: 'Hello',
  35. text: 'Welcome to the team!'
  36. }
  37. }).then(
  38. response => {
  39. console.log(response)
  40. },
  41. reject => {
  42. console.log(reject)
  43. }
  44. )
Add Comment
Please, Sign In to add comment