瀏覽代碼

postgest: apply xhr config before additional xhr hook

master
Bing Sun 5 年之前
父節點
當前提交
986413d433
簽署人: sunb GPG Key ID: F7795F8C590626AB
共有 1 個文件被更改,包括 10 次插入1 次删除
  1. +10
    -1
      src/postgrest.js

+ 10
- 1
src/postgrest.js 查看文件

@@ -110,11 +110,20 @@ export default (api_root, auth={}) => {


// 2. return values on Prefer // 2. return values on Prefer
// if (['POST', 'PATCH'].includes(options.method) && options.headers && !options.headers.Prefer) // if (['POST', 'PATCH'].includes(options.method) && options.headers && !options.headers.Prefer)
if (['POST', 'PATCH'].includes(options.method))
if (['POST', 'PATCH'].includes(options.method)) {
// if the config is already set
let _old_config = options.config

options.config = xhr => { options.config = xhr => {
// apply the provided xhr config
let _old_config_xhr = _old_config(xhr)
if (_old_config_xhr)
xhr = _old_config_xhr

xhr.setRequestHeader('Prefer', 'return=representation') xhr.setRequestHeader('Prefer', 'return=representation')
return xhr return xhr
} }
}


// normalize params: since options.params is an object, it cannot support // normalize params: since options.params is an object, it cannot support
// duplicated query keys, while postgrest supports that. // duplicated query keys, while postgrest supports that.


Loading…
取消
儲存