Skip to content
Advertisement

How to Display Value Created from API Onto My Browser?

So I am working with this API and it auto calculates the delivery fee based on the address you input.

Here’s the API docs I am using https://developer.doordash.com/en-US/api/drive#operation/DeliveryQuote

So when I add my values to my form and get my data, it logs the fee in my console like this

enter image description here

My issue is how do I get this value from the data field?

I tried to do

JavaScript

But it says fee is not defined?

I also tried fee: "" and that doesn’t work either.

I even put console.log(data.fee) and it says data is not defined

My last attempt I change it to console.log(response.fee) and it still showed undefined in the console?

How do I even get the fee value to console.log?

Note I am using express and for my tip value I have my input form named “item1” so I can access it by saying req.body.item1 to get that value

However, for the fee value its auto generated by the API, so I can’t change it or update it manually myself.

Advertisement

Answer

Try using

JavaScript

And I am not sure what your client.createDelivery does. If it sends response, then you need to display it like

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement