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

154
Vistas
Trying to add elements to an array after receiving an response from an API

So basically im interacting with an online Video Poker(jacks or better) API, and i want to create an bot that automatically take decisions for me, the api requests are working fine, but i want the bot to take the decision of keep/helding the cards of the initalHand for me, following there is my code

let bodyReq = {variables:{currency:currency,amount:betAmount},query: "mutation VideoPokerBet($amount: Float!, $currency: CurrencyEnum!) {\n  videoPokerBet(amount: $amount, currency: $currency) {\n    ...CasinoBet\n    state {\n      ...CasinoGameVideoPoker\n    }\n  }\n}\n\nfragment CasinoBet on CasinoBet {\n  id\n  active\n  payoutMultiplier\n  amountMultiplier\n  amount\n  payout\n  updatedAt\n  currency\n  game\n  user {\n    id\n    name\n  }\n}\n\nfragment CasinoGameVideoPoker on CasinoGameVideoPoker {\n  playerHand {\n    suit\n    rank\n  }\n  initialHand {\n    suit\n    rank\n  }\n  handResult\n}\n"}

let bodyHeld = {variables:{identifier:identifier,held:[]},query: "mutation VideoPokerNext($held: [VideoPokerNextHeldInput!]!, $identifier: String!) {\n  videoPokerNext(held: $held, identifier: $identifier) {\n    ...CasinoBet\n    state {\n      ...CasinoGameVideoPoker\n    }\n  }\n}\n\nfragment CasinoBet on CasinoBet {\n  id\n  active\n  payoutMultiplier\n  amountMultiplier\n  amount\n  payout\n  updatedAt\n  currency\n  game\n  user {\n    id\n    name\n  }\n}\n\nfragment CasinoGameVideoPoker on CasinoGameVideoPoker {\n  playerHand {\n    suit\n    rank\n  }\n  initialHand {\n    suit\n    rank\n  }\n  handResult\n}\n"}

async function vpokerBet() {
    try{
    running.style.color = "lightgreen"
    let respData;
    while(true) {
        respData = await (await fetch(url, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "Accept": "application/json",
                "x-access-token": apikey,
            },
            body: JSON.stringify(
                bodyReq
            )
        })).json()
        do{
        respData = await (await fetch(url, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "Accept": "application/json",
                "x-access-token": apikey,
            },
            body: JSON.stringify(
                bodyHeld
            )
        })).json()}while(respData.data.videoPokerBet.active == true)

Basically Lets say for Example it returns an response in which the data of the InitalHand has drawn 4 K's , i want to append those cards to the held: [] Array in let bodyHeld so my next request will have keep those 4 K's, im struggling to finding out how i can do it, any help would be much appreciated ! , thanks ! :)

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