How to send HTML Email Data to Xano?
Options
![Oliver Burrell](https://us.v-cdn.net/6037124/user_avatars/1677616.jpg)
Oliver Burrell
Member ✭
I have HTML email data created by a drag-and-drop email editor and stored in a text variable to send to Xano/Sendgrid. I tried to post the HTML as a JSON field which obviously doesn't work because HTML has similar delimiters like " in the code. So, I wonder what is the best way to convert the HTML email data so that I can send it in the post request to Xano?
Comments
-
you would use the Set Header function (under Utility Functions) to set your Content-type: text/html
[CleanShot 2022-08-18 at 10.11.24.png] -
It depends on exactly what you are trying to do and from what context, but if you make an HTML string, and then encode that string in JSON, you'll be able to have the info come over as a JSON payload. So if using JS, I would
(assuming variable html is a string in scope)
const obj = {}
obj.html = html
obj.hello="hi"
const json = JSON.stringify(obj);
const response = await fetch("https://my-xano-instance.xano.com/path-to-endpoint", { method: "POST" body: json });
const resultObj = await response.json()
and then resultObj is whatever Xano sent back! -
Thanks very much ! I wondered if JSON.stringify could convert html as well, but wasn't sure. I'll try it out ...
-
Yes, that worked nicely! Thanks
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback