Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda