【问题标题】:How to access MongoDB atlas through https API?如何通过 https API 访问 MongoDB 图集?
【发布时间】:2021-04-29 17:31:49
【问题描述】:

自从我迁移到 Mongodb Atlas 后,我遇到了 cors 错误

我在 mongodb 仪表板上找到的唯一 URL 是 mongodb+srv://<username>:<password>@cluster0.cnh0m.mongodb.net/myFirstDatabase

这是我的代码:


getClap = async () => {
    try {
        const res = await axios.get(`mongodb+srv://...`)
        console.log(res.data);
    } catch (err) console.error(err);
};

有什么方法可以像以前使用 mlab 一样将 mongodb 直接与 axios 连接?使用 HTTPS 地址?

【问题讨论】:

    标签: reactjs mongodb axios mongodb-atlas


    【解决方案1】:

    我通过阅读 mlab 文档找到了答案。

    问。 Atlas 有数据 API 吗?

    如果您使用的是 mLab 数据 API,请注意 MongoDB Atlas 没有 有一个数据 API。但是,我们已经开源了 mLab 数据 API 和 让您可以轻松地在 Heroku 上自行托管 mLab 数据 API。

    一旦您重新配置应用程序以使用您的自托管 mLab 数据 API,您将能够迁移 mLab 托管的部署 到 MongoDB Atlas。

    source link

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-05
      相关资源
      最近更新 更多