Sendgrid-nodejs: React-native support?

Created on 12 Apr 2016  路  12Comments  路  Source: sendgrid/sendgrid-nodejs

Does this module support use in a react-native app? I'm looking for a simple way to background mail using an API. Thanks!

Most helpful comment

Thanks. I've found that using fetch works well for sending simple emails using the web api from React Native:

fetch('https://api.sendgrid.com/v3/mail/send', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ' + apikey,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
}).then((response) => {
  this.setState({response: `${response.status} - ${response.ok}`});
});

All 12 comments

simulator_screen_shot_apr_15__2016__16_40_06

@flizzer,

I have not tested our module in react-native, but based on @penjual's error, perhaps this thread can help: https://github.com/facebook/react-native/issues/4968

Please let me know how it goes. Thanks!

Did you figure out how to get SendGrid working with React Native? I'm getting the same error message.

@rdagger No, I didn't. Ended up using a .NET web api 2 web service to interact with SendGrid. Repo here if you're interested in having a look. Good luck!

@rdagger, @flizzer,

We are just about to bring v9 out of beta, hopefully that will help you: https://github.com/sendgrid/sendgrid-csharp/tree/v9beta

@thinkingserious Thanks, are you also releasing a new Node.js version for React Native?

Hello @rdagger,

We are not releasing a version specifically targeting React Native, but we are working on similar improvements that we made to our C# SDK.

Do you have an ETA for the new Node.js release? Is it possible to try out the beta now?

Hello @rdagger,

I don't have an ETA yet. We have not left the planning stages just yet. If you would like to participate, please see the "Mail Helper Enhancement (v3 mail/send)" project here: https://github.com/sendgrid/sendgrid-nodejs/projects

With Best Regards,

Elmer

Thanks. I've found that using fetch works well for sending simple emails using the web api from React Native:

fetch('https://api.sendgrid.com/v3/mail/send', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer ' + apikey,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify(body),
}).then((response) => {
  this.setState({response: `${response.status} - ${response.ok}`});
});

@rdagger What all did you contain in your body? And did you have to import any other modules?

@jaymjax1 I used @rdagger 's solution and I used the following format for for 'body':
let body = { "personalizations": [ { "to": [ { "email": "[email protected]" } ], "subject": "Hello, World!" } ], "from": { "email": "[email protected]" }, "content": [ { "type": "text/plain", "value": "Hello, World!" } ] }
taken from https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html
I did not have to import any other modules. Hope this helps!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kiranshashiny picture kiranshashiny  路  4Comments

TobiahRex picture TobiahRex  路  3Comments

wooyah picture wooyah  路  4Comments

amlcodes picture amlcodes  路  4Comments

thinkingserious picture thinkingserious  路  4Comments