Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

478
Views
Realice una solicitud de publicación de API de Shopify usando Next.js y Koa Router (método 405 no permitido)

No estoy seguro de si se trata de un problema relacionado con Shopify o un problema de codificación general, pero cuando envío una solicitud a la API para Next.js o cómo Shopify ha ejemplificado , aparece un error 405. Estoy usando Koa Router (eso fue lo que Shopify ha precompilado con su configuración estándar de Auth) y MongoDB.

servidor.js

 import addTest from "../helpers/add"; ... router.post("/api/add", async (ctx) => { try { /* Get the shop from the authorization header to prevent users from spoofing the data */ shopDomain = await getShopUrlFromSession(ctx.req, ctx.res); if (shopDomain) { addTest(ctx.req, ctx.res); } res.status(201).send(response[0]); } catch (error) { res.status(500).send(error.message); } });

agregar.js

 import connectMongo from "../../../utils/connectMongo"; import { Shopify } from "@shopify/shopify-api"; import Test from "../../../models/testModel"; export default async function addTest(req, res) { try { console.log("CONNECTING TO MONGO"); await connectMongo(); console.log("CONNECTED TO MONGO"); const session = await Shopify.Utils.loadCurrentSession(req, res, true); const client = new Shopify.Clients.Graphql( session.shop, session.accessToken ); const shopId = `https://${session.shop}`; console.log("CREATING DOCUMENT"); const test = await Test.create(req.body); console.log("CREATED DOCUMENT"); res.json({ test }); } catch (error) { console.log(error); res.json({ error }); } }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!