How can I get data from a response payload <script>

我只是一个虾纸丫 提交于 2021-02-11 13:02:24

问题


Let's say I have a function that runs fetch() to send an asynchronous GET request that returns a response with the following payload:

<script type="text/javascript">
    var csrfToken = "ImJmMWIxZjI0ZGRmMTA1ZGVkYWQ5NThlNThlYjM3OTYzYmRhNmRiMDAiU"
</script>

How can I access the csrfToken variable in Vue?

When I access the response body it converts that whole body into a giant string rather than running the JS and making the variable available for use.

来源:https://stackoverflow.com/questions/65499966/how-can-i-get-data-from-a-response-payload-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!