How to get Custom Headers in Webhook Response?

I’m returning a webhook response with a custom header '“totalResults” to my webpage via jQuery POST

In Chrome DEVtools I see this under response headers

Access-Control-Allow-Origin: *
Cf-Cache-Status: DYNAMIC
Cf-Ray: 87b6b07cbc916045-SIN
Content-Length: 74410
Date: Sun, 28 Apr 2024 11:25:06 GMT
Server: cloudflare
Totalresults: 27
X-Powered-By: Make Gateway/production

I tried:

console.log( request.getResponseHeader(‘Totalresults’) );
console.log( request.getResponseHeader(‘totalresults’) );
console.log( request.getResponseHeader(‘totalResults’) );

but keep getting NULL

when I try :
console.log(request.getAllResponseHeaders() );
I only get content-length: 74410

Is there something I need to do to expose my custom header?

(async () => {
  const resp = await fetch('');
  const total = resp.headers.get('Totalresults');
1 Like

Do you have a solution for Ajax instead of fetch?

fetch() is already a mechanism that lets a user make AJAX calls with JavaScript.

1 Like

I found an easy way already without having to change my script, by just adding Access-Control-Expose-Headers


Hello @BruceP :wave:

Just wanted to jump in and congratulate you for the great job you and @samliew did while figuring out the solution for your problem.

Keep up the great work!