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

239
Vistas
How to return a JSON list in the following format

I am using the bubble.io plugin builder. To return a response under bubble.io's api connector, all parameters returned must have the prefix "p". In the following case, this returns the correct results for an api call.

const options = {
    url: url
    ,method: method
    ,headers: {
        "Content-Type": "application/json"
    }
}
const response = context.request(options);
    console.log(response);
    
/* 

The model we will use 
{
  "mins": 5,
  "price": "34823.91104827"
}

*/

var body = JSON.parse(response.body);

const {convert} = require('json-to-bubble-object');
    
let returnlist = []
returnlist.push(     {
  "_p_mins": body.mins.toString(),
  "_p_price": body.price,
  "_p_api_response": JSON.stringify(convert(body))
 
})
 
    return {
        "result": returnlist
    
    }

This call generates the following response:

_p_api_response: "{"_p_mins":5,"_p_price":"36703.73207769"}"
_p_mins: "5"
_p_price: "36703.73207769"

What I am trying to do is use the module 'json-to-bubble-object' as returned in the _p_api_response parameter (which is a test parameter and is not actually needed) to return the data. This makes my call dynamic so I don't have to manually specify the parameters for each different api call.

Hence, I am trying to make the API call look something like this:

var body = JSON.parse(response.body);

const {convert} = require('json-to-bubble-object');
    
let returnlist = []
returnlist.push(     JSON.stringify(convert(body))
 
 
)
 
    return {
        "result": returnlist
    
    }

but this returns null results

_p_api_response: null
_p_mins: null
_p_price: null

can someone let me know how I can return the data generated from the convert function as a list as done in the first request? Thanks

EDIT: For clarification, the p prefix allows the response headers to be viewed in the bubble.io builder, as seen in the below image.

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I dont have enough reputation to comment but

I am unable to repro your problem. You can view my repro here:

https://runkit.com/runkitname/so-a-nodejs

const {convert} = require('json-to-bubble-object');

var body = {
    "mins": 5,
    "price": "34823.91104827"
}

body.api_response = JSON.stringify(convert(body))


let returnlist = []
returnlist.push(convert(body))

console.log({"result": returnlist})

console

{
  result: [
    {
      _p_mins: 5,
      _p_price: '34823.91104827',
      _p_api_response: '{"_p_mins":5,"_p_price":"34823.91104827"}'
    }
  ]
}
about 4 years ago · Juan Pablo Isaza Denunciar
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