0

有没有办法将 WIX Corvid API 用于外部应用程序来检索产品数据。我找不到我们可以使用的 SDK。我们的客户想要从不同的平台管理它的产品。我们想要一种从 WIX 商店创建/更新/获取产品和订单的方法。

4

2 回答 2

0

您需要使用HTTP 函数来公开您的站点 API。然后,您可以通过外部应用程序将 POST 请求发送到您站点的端点,并根据请求参数或正文,您可以查询您的产品数据(在数据库集合中提供)并将项目返回给外部服务。

就创建/更新/获取而言,您只能在 Wix 商店后端 API 允许的范围内执行此操作:https ://www.wix.com/corvid/reference/wix-stores-backend.html

于 2020-05-18T17:45:50.730 回答
0

确保您没有收到 CORS 错误:

将以下来源字符串更改为您自己的来源。

这应该可以解决您的 CORS 问题。

import {ok, badRequest, response} from 'wix-http-functions';

function validate(origin) {
    if (origin == "http://localhost:4200" || origin == "http://localhost:4201") {
        return true;
    } else {
        return false;
    }
}

export function options_yourFunctionName(request) {
    console.log(request);

    let headers = {
        "Access-Control-Allow-Methods": "POST, GET, OPTIONS",
        "Access-Control-Max-Age": "86400"
    }

    if (validate(request.headers.origin)) {
        headers["Access-Control-Allow-Origin"] = request.headers.origin;
    }

    return response({ "status": 204, "headers": headers });
}


export function post_yourFunctionName(request) {
    console.log("post_duxLogin");
    const _response = {
        "headers": {
            "Content-Type": "application/json",
        }
    };

    if (validate(request.headers.origin)) {
        _response.headers["Access-Control-Allow-Origin"] =
            request.headers.origin;
        _response.headers["Access-Control-Allow-Headers"] = "Content-Type";
    }

    // Perform other things here....
}

于 2021-08-10T12:57:52.617 回答