Axios GET Request with Authorization and New Window Opening
This\scode\ssnippet\smakes\san\sHTTP\sGET\srequest\susing\sthe\sAxios\slibrary.\sThe\srequest\sincludes\sthe\swithCredentials\soption\sset\sto\strue\swhich\sallows\sthe\sbrowser\sto\ssend\scookies\salong\swith\sthe\srequest.\sThe\srequest\salso\sincludes\san\sAuthorization\sheader\swith\sa\stoken\sobtained\sfrom\sthe\sgetToken()\sfunction.\n\nIf\sthe\srequest\sis\ssuccessful,\sit\sopens\sa\snew\sbrowser\swindow\susing\sthe\swindow.open()\smethod.\sThe\slinkUrl\sparameter\sis\sused\sas\sthe\sURL\sfor\sthe\snew\swindow,\sand\s"_blank"\sspecifies\sthat\sthe\snew\swindow\sshould\sbe\sopened\sin\sa\snew\stab\sor\swindow\s(depending\son\sthe\suser's\sbrowser\ssettings).\sThe\sparams\svariable\sis\sused\sto\sspecify\sadditional\sparameters\sfor\sthe\snew\swindow.\n\nIf\sthe\srequest\sfails,\sthe\serror\sis\slogged\sto\sthe\sconsole.
原文地址: https://www.cveoy.top/t/topic/pFUv 著作权归作者所有。请勿转载和采集!