You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用Parse.Cloud.httpRequest提示‘不是函数’的问题求助

问题原因及解决方案

这个错误的核心原因是Parse Server版本更新后,HTTP请求的API位置发生了变更——在较新的Parse Server版本中,Parse.Cloud.httpRequest方法已被移除,官方将HTTP请求功能直接放到了Parse根对象下,改为Parse.httpRequest。

修改后的云函数代码

Parse.Cloud.define("testHTTP", async (request) => {
  try {
    const httpResponse = await Parse.httpRequest({
      url: 'http://www.google.com/search',
      params: {
        q : 'Sean Plott'
      }
    });
    console.log(httpResponse.text);
    return httpResponse.text;
  } catch (httpResponse) {
    console.error('Request failed with response code ' + httpResponse.status);
    return 'Request failed with response code ' + httpResponse.status;
  }
});

额外说明

  1. 上面的代码用async/await替代了原代码里的then/catch,逻辑更直观,也和你原函数的async声明更匹配。
  2. 如果你的Parse Server是非常旧的版本(比如2.x及以前),Parse.Cloud.httpRequest原本是有效的,但这类旧版本早已停止维护,建议尽快升级到最新稳定版。

内容的提问来源于stack exchange,提问作者Boberski

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 03:22:39