使用typescript和webpack在axios的httpheader中设置access_token

时间:2018-05-13 06:48:28

标签: asp.net-mvc typescript razor single-page-application axios

我想在axios的标题中设置access_token,如下所示。

https://github.com/axios/axios#global-axios-defaults

现在我使用razor语法获取access_token,该语法仅在CSHTML文件中可用。

https://github.com/IdentityServer/IdentityServer4.Samples/blob/release/Clients/src/MvcHybrid/Views/Home/Secure.cshtml

我正在使用带有JavascriptServices

的vue.js的typescript

如何在我的打字稿文件中设置(传递)此等待Context.GetTokenAsync(&#34; access_token&#34;)(比如说boot.ts)以设置为axios默认值。< / p>

1 个答案:

答案 0 :(得分:0)

我跟随以下作为替代方案。所以不需要上面的用例。

https://github.com/aspnet/Razor/issues/2347