0
HTTParty
url = "https://my-url/locomotive/api/tokens.json" response = HTTParty.post(url, body: { :api_key => @api_key })
在服務器上:
Started POST "/locomotive/api/tokens.json" for 202.4.224.66 at 2014-06-15 17:59:57 +1000 Processing by Locomotive::Api::TokensController#create as JSON Parameters: {"api_key"=>"5fcfe580e42944c896a49469c30aa97a384b497d"}
$ HTTP
$http({ url: 'https://ernie-locomotive.12wbt.com/locomotive/api/tokens.json', method: 'POST', params: data });
Started OPTIONS "/locomotive/api/tokens.json?api_key=5fcfe580e42944c896a49469c30aa97a384b497d" for 59.167.21.65 at 2014-06-15 17:53:43 +1000 Processing by Locomotive::Public::PagesController#show as JSON Parameters: {"api_key"=>"5fcfe580e42944c896a49469c30aa97a384b497d", "path"=>"locomotive/api/tokens"} WARNING: Can't verify CSRF token authenticity
基本上,我認爲他們是兩個相同的方法。似乎$http
不傳遞http方法。 HTTParty完成它的請求並正確地抓取結果。
這是否意味着,該角不處理? –
@JackieChan它不是角度相關的...它是關於瀏覽器如何與跨源請求一起工作的。角度的工作確定與這樣的請求 - 但你需要設置你的服務器返回適當的CORS頭預檢請求 –
Got亞....任何有用的角度資源? –