Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

155
Vistas
Variable not being passed from front end to backend

I'm scratching my head at this problem, I'm implementing Instagrams basic display API using Wix's new editor-x. My code works if I run it on the client side, I get an access token, however it doesn't when I import the getAccessToken function from the server side, the function runs but I get an invalid auth code.

I think there maybe an issue passing the code variable?

frontend code:

import wixLocation from 'wix-location'
import {getAccessToken} from 'backend/instagram'
let query = wixLocation.query; //get auth code from URL param
    let code = query.code
    console.log(code) //check code is correct
    if(code){
        const token = await getAccessToken(code) //request accesstoken
        console.log(token) //log token
        }

backend code:

import {fetch} from 'wix-fetch'
export async function getAccessToken(code) {
    const url = "https://api.instagram.com/oauth/access_token"
    const options = {
        method: "POST",
        headers: {
            "Content-Type": "application/x-www-form-urlencoded"
        },
        body: `client_id=id&client_secret=secret&grant_type=authorization_code&redirect_uri=uri&code=${code}`
    }
    try {
        const data = await fetch(url,options)
        const token = await data.json()
        return token
    } catch(error) {
        return error
    }
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda