Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- axios({
- url: 'https://api:[email protected]/v3/somesandboxdomain1c.mailgun.org/messages',
- method: 'post',
- username: 'api',
- password: 'key-somekey',
- data: {
- from: "Excited User <[email protected]>",
- to: "[email protected]",
- 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 <[email protected]>',
- to: '[email protected]',
- subject: 'Hello',
- text: 'Welcome to the team!'
- }
- }).then(
- response => {
- console.log(response)
- },
- reject => {
- console.log(reject)
- }
- )
Add Comment
Please, Sign In to add comment