Skip to content

process hook 支持异步处理 #68

@tommytroylin

Description

@tommytroylin

https://github.com/jias/natty-fetch/blob/d8b31896b41a0e6b2e463615796d8b8b55e0e3c2/src/request.js#L88-L92

当前natty-fetch的数据处理仅支持同步方式。
在使用中由于服务器端启用的一些防护措施需要进行异步地数据校验和处理。并且本次异步处理后才会返回真实的响应。

考虑在此处提交pr增加异步的支持方式,请看下是否支持这样做。

const content = config.process(response.content, vars)
if (content.then && typeof content.then === 'function') { // 返回 thenable
  content.then(c => this.onSuccess(c)
} else {
  this.onSuccess(content)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions