Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- axios({
- url: 'https://api:key-someapikey@api.mailgun.net/v3/somesandboxdomain1c.mailgun.org/messages',
- method: 'post',
- username: 'api',
- password: 'key-somekey',
- data: {
- from: "Excited User <mailgun@some.example.org>",
- to: "myemail@gmail.com",
- subject: "Hello from react app",
- text: "Testing some Mailgun awesomness!"
- },
- headers: {
- "Content-Type": "application/x-www-form-urlencoded",
- 'Authorization': `Basic ${window.btoa('api:key-someapikey')}`
- }
- })
- .then(function (response) {
- console.log(response);
- })
- .catch(function (error) {
- console.log(error);
- });
- 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.
- axios({
- method: 'post',
- url: `${mailgun.baseUrl}/${mailgun.domain}/messages`,
- auth: {
- username: 'api',
- password: mailgun.apiKey
- },
- params: {
- from: 'Awesome Development Team <noreply@yourdomain.com>',
- to: 'testing@example.com',
- subject: 'Hello',
- text: 'Welcome to the team!'
- }
- }).then(
- response => {
- console.log(response)
- },
- reject => {
- console.log(reject)
- }
- )
Add Comment
Please, Sign In to add comment