Shopify PUT请求在选项操作前失败404

时间:2018-09-14 14:11:57

标签: http shopify axios put http-options-method

我正在从我的应用程序中使用AXIOS来访问shopify管理员api。我正在使用元字段(据我所知,店面API不支持graphql)更新客户。进行PUT时收到预检选项错误。错误是404。实际上,我尝试打的项目确实存在,所以我想知道shopify是不是对请求的处理错误,还是我的配置中缺少某些内容。

注意:我可以通过邮递员成功地执行相同的请求。据我所知,Postman并未进行期权预检。

我的代码:

axios({
    method: 'PUT',
    url: `https://${SHOPIFY_SHOP}/admin/customers/${decodedId}.json`,
    auth: {
      username: SHOPIFY_BASIC_AUTH_USERNAME,
      password: SHOPIFY_BASIC_AUTH_SECRET,
    },
    data: {
      customer: {
        id: decodedId,
        metafields: [
          {
            namespace: 'custom_fields',
            key: 'organization',
            value: org,
            value_type: 'string',
          },
          {
            namespace: 'custom_fields',
            key: 'token_pro',
            value: isPro,
            value_type: 'integer',
          },
        ],
      },
    },
  }).then((data) => {
    debugger
  }).catch(( error ) => {
    debugger
  });

错误

OPTIONS https://SHOP_NAME.myshopify.com/admin/customers/776734343229.json 404 (Not Found)

Failed to load https://SHOP_NAME.myshopify.com/admin/customers/776734343229.json: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'localhost:3000' is therefore not allowed access.

请注意,在进行此axios呼叫时,客户确实存在。

0 个答案:

没有答案