Soweneed a libraryforhandlinganemailandthenlastly, wejustneedthelibrarytohandleenvironmentvariablesbecauseour E mailserviceisgonnahavean A p i kethatweneedtosendit.
Sothere's a functioninsideofhere, andthisfunctionallowsyoutoessentiallyrightjavascriptasifyouwereonthefrontendofthatapplication.
Sowehaveaccesstothedocument, forexample, wecouldjustsaydocumentgetelementby I d.
Andwecangetanelementwiththatpriceblockourprice, I d.
Soit's copythatinhere.
Now, whatwe'vedoneiswe'vegonetothateuro.
We'vewaiteduntilourelementisshownonthepage, andthenwe'reevaluatingsomecodetosaygivemetheelementwiththat, I d Andwejustwanttogetthetextinsideofitandsowillsayinourtext.
Weneedtomakesurethatweactuallyawaitnightmarebecausethisisall a synchronous.
Soweneedtomakesureweput a weighthere, sothatisactuallywaitingthatcodeandthenrunningeverythingoverhereand I'm justgonnatidythiscodeupjust a littlebit, soit's easiertoread.
Andnowthatwehave a pressstring, wecanmoveontoactuallyparsingthestringinto a particularprice.
Soifwecouldjustcomedownhere, wecansaywewant a pricenumberwhichisgoingtobeequaltoourpricestring.
Andallwewanttodoisreplacethedollarsignbecauseasyouremember, there's a dollarsigninsideofthisstring.
Sowejustwanttoreplacethedollarsignwithnothing.
Andthen, ofcourse, makesurethatweturnthisinto a number.
Sowe'llsayparsefloatofthat.
Sonowwhatwe'redoingiswe'rereplacingthedollarsignsthatwehavejust a singlenumberandthenwe'reconvertingthatstringinto a numberandstoringitinthispricenumbervariable.
Now, inordertoactuallystartsending e mails, whatweneedtodoisgotosendgridswebsiteandwejustneedtocreateanaccountandloginwhich I havealreadydone.
AndthegreatthingaboutsendGridswebsiteisthatyoucanactuallysend a tonof e mailseverymonthcompletelyforfreeaslongasyoustayunderthethreshold.
I wanttosayit's either 500 or 5000 emails a month, whichifyou'reusingthissimpleapplication, you'renevergoingtosurpassthatfreelimitthattheygiveyou, whichisabsolutelygreatandallyouneedtodoinordertofindyourAPikey.
Youjustneedtogodowntosettingsandyoucanseethere's a P I keysrighthereon.
WhatyouwanttodoisyouwanttocreateanAP I kethathasaccesstosendmailandourcase I'vecreatedthis a P I Q.
Righthere.
Let's justcreate a brandnew a peakywecansaythatwewantedtohaverestrictedaccess.
Ifwescrolldown, youshouldseemailsend, andallwewanttodoisbuild a letthemsendmail.
Sonowthatwehavethatcopied, let's gobackoverintoourcodeandinourenvironmentvariable, wecancreate a variablewhichwewantedtocallsendgridap I ke, andwecansetthatequaltothe a p i kethatwejustcopied, whichwecanseeisherenow, withthatoutoftheway, wecouldgobacktoourpart, sir, Andwecanactuallyimportthatenvironmentvariable.
I'm sorry, notstripedSendgrid A p I keyjustlikethat.
Andthat's goingtobeourenvironment.
Variablesthatwesetinourdot n v filehereandwewanttodoiswewanttoactuallysetupandhookupthatlibraryreimportedearlier, whichissendgridsowecansaycreativevariablecalledsendgridmale s G mail.
Wejustcallit E mailhere, andthisobjectisgoingtohaveallofourimportantemailfields.
Forexample, we'regonnahave a twofield.
Andinourcase, what I'vedoneis I'vejustgonetosomefakeeurofakeemailsitescalled 10 emaildotorGE, andit'lljustgiveyou a temporaryemailyoucanusefortestingpurposes.
I'm justgonnacopythisdownpastedinheresowecanactuallyseethe e mailsshowupinsideofthisinboxwhenweactuallysendthemnext.
Weneedtosetfromfield.
Youjustsetthiswhateveryouwant.
I'm gonnacallit a MazonpricecheckeratexampledotcomThisdoesn't reallymatterfromthefromfield.
ThatemailobjectAndthereasonwe'rereturningthisisbecauseit's actuallyreturns a promise.
It's asynchronous.
Soweneedtomakesurethatweawaitthatinsideofourcode.
Now, uphere, wherewecandoiswecanactuallycallthatsendemailfunction, andwewant a firstpass.
It a subjectwhich, speaking, saypriceislowandthenwewanttopassitsomekindofmessage, and I'm actuallygonnapassit a reallyusefulmessagethatwillallowyoutoviewthewebsitefromtheemail.
Itsaysthatwehadanheirandittoldusthemessage, whichisthatthatRandomJubileejustthat I hadtypedoutisnottofindwhichiscorrect, thelastimportantthingthatweneedtomakesurewedo.