Calling External API with Javascript

前端 未结 5 1807
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-14 03:33

I need to make a POST request to an external server from my webpage using Javascript. The body and response are both json. I can\'t figure out how to make this call or what tool

5条回答
  •  鱼传尺愫
    2021-02-14 04:12

    Are you the owner of the destination of the call? If yes, implement the CORS headers in server-side.

    If no, you can fiddle using JSONP (it bypasses CORS) or you can even implement a server-side proxy that you own to route external requests (and of course, implement CORS there).

    Check out the article on CORS in MDN if you want more information : HTTP access control (CORS) on MDN

提交回复
热议问题