Search Contacts

Hey there!

I stuck a bit and would much appreciate your help.

I’m trying to get list of the contacts:

const url = 'https://api.hubapi.com/crm/v3/objects/contacts/search?apikey=...'
const params = { 
 headers: { 'Content-Type': 'application/json' }, 
 method: 'POST', 
 body: JSON.stringify({ query: 'mail@gmail.com' })
}
const res = await fetch(url, params)

The `res` should be a JSON object, as it described here: https://developers.hubspot.com/docs/api/crm/contacts

so, I expect something like:

{
	"total": 1,
	"results": [
	 {
	 "createdAt": "2019-10-30T03:30:17.883Z",
	 "archived": false,
	 "id": "512",
	 "properties": {
	 "property_number": "17",
	 ...
	 }
	 ... 
	 },
	 "updatedAt": "2019-12-07T16:50:06.678Z"
}]
}

but instead I’m getting a Response object:

Response {
 size: 0,
 timeout: 0,
 [Symbol(Body internals)]: { 
 body: [Gunzip], 
 disturbed: false, 
 error: null 
 },
 [Symbol(Response internals)]: { 
 url: 'https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=e7c3f7dc-...',
 status: 200,
 statusText: 'OK',
 headers: [Headers],
 counter: 0 } 
 } 
}

How can I get the ‘results’ array, described in you documentation?

Thanks.

oh… .json() .. :slightly_smiling_face: