Geocoding Address Response does not contain location informaion

2 posts / 0 new
Last post
TwoFistedJustice
Geocoding Address Response does not contain location informaion

I'm using a simple Fetch() to get a forward location. The response I am getting back contains no location information at all. It looks like a bunch of settings and a buffer.

How do I make this work properly?

The docs ( https://developer.mapquest.com/documentation/geocoding-api/address/get/ ) show an example GET response for the example url ( http://www.mapquestapi.com/geocoding/v1/address?key=KEY&location=Washing...)

here is my fetch call

`

const httpOptions = { "method": "get" };

const fetchGeocodeCoordinates = async function(location) {

const encodedLocation = encodeURIComponent(location);

let secret = await getApiKey(secretName);

let url = `http://www.mapquestapi.com/geocoding/v1/address?key=${secret}&location=Washington,DC`;

 

try {

 const httpResponse = await fetch(url, httpOptions);

 if (!httpResponse.ok) {

   throw new Error("Unable to fetch coordinates\n")

}

console.log(httpResponse)

return await httpResponse.json();

}

catch(err) {

  console.log(err.message);

}

};`

 

This is what I get back:

`

{
"url": "http://www.mapquestapi.com/geocoding/v1/address?key=REDACTED&location=Washington,DC",
"status": 200,
"statusText": "OK",
"headers": {
"_headers": {
"date": [
"Sun, 30 May 2021 01:51:07 GMT"
],
"content-type": [
"application/json;charset=UTF-8"
],
"content-length": [
"1044"
],
"connection": [
"close"
],
"access-control-allow-methods": [
"OPTIONS,GET,POST"
],
"access-control-allow-origin": [
"*"
],
"cache-control": [
"no-cache, must-revalidate"
],
"expires": [
"Mon, 20 Dec 1998 01:00:00 GMT"
],
"geocodetransactioncount": [
"1"
],
"last-modified": [
"Sun, 30 May 2021 01:51:07 GMT"
],
"pragma": [
"no-cache"
],
"reversegeocodetransactioncount": [
"0"
],
"server": [
"Apache-Coyote/1.1"
],
"set-cookie": [
"JSESSIONID=2A8F8CA8FA783375E6B6BA314D3FB70F; Path=/; HttpOnly"
],
"status": [
"success"
],
"transactionweight": [
"1.0"
]
}
},
"ok": true,
"body": {
"_readableState": {
"objectMode": false,
"highWaterMark": 16384,
"buffer": {
"head": null,
"tail": null,
"length": 0
},
"length": 0,
"pipes": [],
"flowing": true,
"ended": true,
"endEmitted": true,
"reading": false,
"sync": false,
"needReadable": false,
"emittedReadable": false,
"readableListening": false,
"resumeScheduled": false,
"errorEmitted": false,
"emitClose": true,
"autoDestroy": true,
"destroyed": true,
"errored": null,
"closed": true,
"closeEmitted": true,
"defaultEncoding": "utf8",
"awaitDrainWriters": null,
"multiAwaitDrain": false,
"readingMore": false,
"decoder": null,
"encoding": null
},
"_events": {},
"_eventsCount": 4,
"_writableState": {
"objectMode": false,
"highWaterMark": 16384,
"finalCalled": false,
"needDrain": false,
"ending": true,
"ended": true,
"finished": true,
"destroyed": true,
"decodeStrings": true,
"defaultEncoding": "utf8",
"length": 0,
"writing": false,
"corked": 0,
"sync": false,
"bufferProcessing": false,
"writecb": null,
"writelen": 0,
"afterWriteTickInfo": null,
"buffered": [],
"bufferedIndex": 0,
"allBuffers": true,
"allNoop": true,
"pendingcb": 0,
"prefinished": true,
"errorEmitted": false,
"emitClose": true,
"autoDestroy": true,
"errored": null,
"closed": true
},
"allowHalfOpen": true
},
"bodyUsed": true,
"size": 0,
"timeout": 0,
"_raw": [
{
"type": "Buffer",
"data": [
123,
34,
105,
110,
102,
111,
34,
58,
123,
34,
115,
116,
97,
116,
117,
115,
99,
111,
100,
101,
34,
58,
48,
44,
34,
99,
111,
112,
121,
114,
105,
103,
104,
116,
34,
58,
123,
34,
116,
101,
120,
116,
34,
58,
34,
92,
117,
48,
48,
65,
57,
32,
50,
48,
50,
49,
32,
77,
97,
112,
81,
117,
101,
115,
116,
44,
32,
73,
110,
99,
46,
34,
44,
34,
105,
109,
97,
103,
101,
85,
114,
108,
34,
58,
34,
104,
116,
116,
112,
58,
47,
47,
97,
112,
105,
46,
109,
113,
99,
100,
110,
46,
99,
111,
109,
47,
114,
101,
115,
47,
109,
113,
108,
111,
103,
111,
46,
103,
105,
102,
34,
44,
34,
105,
109,
97,
103,
101,
65,
108,
116,
84,
101,
120,
116,
34,
58,
34,
92,
117,
48,
48,
65,
57,
32,
50,
48,
50,
49,
32,
77,
97,
112,
81,
117,
101,
115,
116,
44,
32,
73,
110,
99,
46,
34,
125,
44,
34,
109,
101,
115,
115,
97,
103,
101,
115,
34,
58,
91,
93,
125,
44,
34,
111,
112,
116,
105,
111,
110,
115,
34,
58,
123,
34,
109,
97,
120,
82,
101,
115,
117,
108,
116,
115,
34,
58,
45,
49,
44,
34,
116,
104,
117,
109,
98,
77,
97,
112,
115,
34,
58,
116,
114,
117,
101,
44,
34,
105,
103,
110,
111,
114,
101,
76,
97,
116,
76,
110,
103,
73,
110,
112,
117,
116,
34,
58,
102,
97,
108,
115,
101,
125,
44,
34,
114,
101,
115,
117,
108,
116,
115,
34,
58,
91,
123,
34,
112,
114,
111,
118,
105,
100,
101,
100,
76,
111,
99,
97,
116,
105,
111,
110,
34,
58,
123,
34,
108,
111,
99,
97,
116,
105,
111,
110,
34,
58,
34,
87,
97,
115,
104,
105,
110,
103,
116,
111,
110,
44,
68,
67,
34,
125,
44,
34,
108,
111,
99,
97,
116,
105,
111,
110,
115,
34,
58,
91,
123,
34,
115,
116,
114,
101,
101,
116,
34,
58,
34,
34,
44,
34,
97,
100,
109,
105,
110,
65,
114,
101,
97,
54,
34,
58,
34,
34,
44,
34,
97,
100,
109,
105,
110,
65,
114,
101,
97,
54,
84,
121,
112,
101,
34,
58,
34,
78,
101,
105,
103,
104,
98,
111,
114,
104,
111,
111,
100,
34,
44,
34,
97,
100,
109,
105,
110,
65,
114,
101,
97,
53,
34,
58,
34,
87,
97,
115,
104,
105,
110,
103,
116,
111,
110,
34,
44,
34,
97,
100,
109,
105,
110,
65,
114,
101,
97,
53,
84,
121,
112,
101,
34,
58,
34,
67,
105,
116,
121,
34,
44,
34,
97,
100,
109,
105,
110,
65,
114,
101,
97,
52,
34,
58,
34,
68,
105,
115,
116,
114,
105,
99,
116,
32,
111,
102,
32,
67,
111,
108,
117,
109,
98,
105,
97,
34,
44,
34,
97,
100,
109,
105,
110,
65,
114,
101,
97,
52,
84,
121,
112,
101,
34,
58,
34,
67,
111,
117,
110,
116,
121,
34,
44,
34,
97,
100,
109,
105,
110,
65,
114,
101,
97,
51,
34,
58,
34,
68,
67,
34,
44,
34,
97,
100,
109,
105,
110,
65,
114,
101,
97,
51,
84,
121,
112,
101,
34,
58,
34,
83,
116,
97,
116,
101,
34,
44,
34,
97,
100,
109,
105,
110,
65,
114,
101,
97,
49,
34,
58,
34,
85,
83,
34,
44,
34,
97,
100,
109,
105,
110,
65,
114,
101,
97,
49,
84,
121,
112,
101,
34,
58,
34,
67,
111,
117,
110,
116,
114,
121,
34,
44,
34,
112,
111,
115,
116,
97,
108,
67,
111,
100,
101,
34,
58,
34,
34,
44,
34,
103,
101,
111,
99,
111,
100,
101,
81,
117,
97,
108,
105,
116,
121,
67,
111,
100,
101,
34,
58,
34,
65,
53,
88,
65,
88,
34,
44,
34,
103,
101,
111,
99,
111,
100,
101,
81,
117,
97,
108,
105,
116,
121,
34,
58,
34,
67,
73,
84,
89,
34,
44,
34,
100,
114,
97,
103,
80,
111,
105,
110,
116,
34,
58,
102,
97,
108,
115,
101,
44,
34,
115,
105,
100,
101,
79,
102,
83,
116,
114,
101,
101,
116,
34,
58,
34,
78,
34,
44,
34,
108,
105,
110,
107,
73,
100,
34,
58,
34,
50,
56,
50,
55,
55,
50,
49,
54,
54,
34,
44,
34,
117,
110,
107,
110,
111,
119,
110,
73,
110,
112,
117,
116,
34,
58,
34,
34,
44,
34,
116,
121,
112,
101,
34,
58,
34,
115,
34,
44,
34,
108,
97,
116,
76,
110,
103,
34,
58,
123,
34,
108,
97,
116,
34,
58,
51,
56,
46,
56,
57,
50,
48,
54,
50,
44,
34,
108,
110,
103,
34,
58,
45,
55,
55,
46,
48,
49,
57,
57,
49,
50,
125,
44,
34,
100,
105,
115,
112,
108,
97,
121,
76,
97,
116,
76,
110,
103,
34,
58,
123,
34,
108,
97,
116,
34,
58,
51,
56,
46,
56,
57,
50,
48,
54,
50,
44,
34,
108,
110,
103,
34,
58,
45,
55,
55,
46,
48,
49,
57,
57,
49,
50,
125,
44,
34,
109,
97,
112,
85,
114,
108,
34,
58,
34,
104,
116,
116,
112,
58,
47,
47,
119,
119,
119,
46,
109,
97,
112,
113,
117,
101,
115,
116,
97,
112,
105,
46,
99,
111,
109,
47,
115,
116,
97,
116,
105,
99,
109,
97,
112,
47,
118,
53,
47,
109,
97,
112,
63,
107,
101,
121,
61,
98,
80,
53,
109,
76,
51,
105,
49,
101,
50,
81,
65,
119,
111,
53,
65,
82,
89,
117,
57,
99,
113,
98,
107,
57,
107,
99,
65,
84,
109,
118,
88,
38,
116,
121,
112,
101,
61,
109,
97,
112,
38,
115,
105,
122,
101,
61,
50,
50,
53,
44,
49,
54,
48,
38,
108,
111,
99,
97,
116,
105,
111,
110,
115,
61,
51,
56,
46,
56,
57,
50,
48,
54,
50,
44,
45,
55,
55,
46,
48,
49,
57,
57,
49,
50,
124,
109,
97,
114,
107,
101,
114,
45,
115,
109,
45,
53,
48,
51,
49,
56,
65,
45,
49,
38,
115,
99,
97,
108,
101,
98,
97,
114,
61,
116,
114,
117,
101,
38,
122,
111,
111,
109,
61,
49,
50,
38,
114,
97,
110,
100,
61,
49,
57,
52,
48,
52,
54,
49,
49,
53,
54,
34,
125,
93,
125,
93,
125
]
}
],
"_abort": false,
"_bytes": 1044
}`

 


TwoFistedJustice
I solved this

`console.log(httpResponse)` should have read `console.log(httpResponse.json())`

That's it. It was so simple that I missed it entirely.