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

84
Visualizações
Update Front End HTML with Back End API Data Conflict

So I have this delivery app and in order for me to get the delivery fee, I need to manually type the address and then submit the form so that the API can get the info and auto calculate the delivery fee.

In my HTML I have the basic setup

<p id="foodTotal">Food Total $0.00</p>
<p id="fee">Delivery Fee $0.00</p>

So when I choose my food items to order, my JS updates the HTML for the food total and would display

Food Total $10.00 //example

However, my delivery fee I don't know how to update this value since it is not something I can just code in Javascript and write like below because the fee is only calculated after I type in my address info.

document.getElementById("fee").textContent = `Your order total is: ${(fee)}`

Note I am using express to collect my form data and update the API

In my app.post function I am using an SDK and code looks like this. Note I don't have to put the fee value in my response since that is already auto calculated by the api, so adding fee: .... does nothing because I can't manually update that value, only the API can change it based on the address distance.

app.post(
  "/https://openapi.doordash.com/drive/v2/deliveries",
  async (req, res) => {
    const client = new DoorDashClient(
      {
        developer_id: process.env.DEVELOPER_ID,
        key_id: process.env.KEY_ID,
        signing_secret: process.env.SIGNING_SECRET,
      },
   );

    const response = await client.createDelivery(
      {
        external_delivery_id: uuidv4(), // keep track of the generated id here or in the response
        pickup_address: "Address 123 XYZ Street",
        pickup_phone_number: "+18001234567",
        dropoff_contact_given_name: req.body.dropoff_contact_given_name,
        dropoff_address: req.body.street + req.body.city + req.body.zipcode,
        order_value: req.body.item1,
      },
    );

So when I run node index.js I get all my data in my console showing exactly the fee, order_value, address etc... and I can also display this data onto another page after submitting by including simple html below my function.

However, I don't see how I would be able to update the first page of my app with the delivery fee automatically without manually submitting the form info first?

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