Fetch error

I use this code to send contact to activecampaign:
Backend

import { fetch } from 'wix-fetch';

export function getApiKey() {
 const key = 'Key';
 const name = 'giovanni';
 const email = 'giovanni@gmail.com';
 const URL = 'url';

 return fetch(URL, {
 'method': 'post',
 'headers': {
 'Content-Type': 'application/x-www-form-urlencoded',
 'api-key': 'key'
            },
 'contact': {
 'first_name': name,
 'email': email
            }
        })
        .then((httpResponse) => {
 if (httpResponse.ok) {
 return httpResponse.json();
            } else {
 return Promise.reject("Fetch did not succeed");
            }
        })
        .then((json) => console.log(json.someKey))
        .catch(err => console.log(err));
}

Page

import {getApiKey} from 'backend/activecampaign.jsw'

$w.onReady(function () {
    getApiKey();
});

But it return me this error:
invalid json response body at http://…/admin/ reason: Unexpected token < in JSON at position 1

How can i fix?

It’s not so clear.

  1. Are you using a json or ‘Content-Type’: ‘application/x-www-form-urlencoded’,?

  2. Shouldn’t your request have a body ?

I have to use ‘Content-Type’ for send information to activecampaign

And i tried add the body like this but it return the same error:

import { fetch } from 'wix-fetch';

export function getApiKey() {
 const key = 'Key';
 const name = 'giovanni';
 const email = 'giovanni@gmail.com';
 const URL = 'url';

 return fetch(URL, {
 'method': 'post',
 'headers': {
 'Content-Type': 'application/x-www-form-urlencoded',
 'api-key': 'key'
            },
 'body': { 
 'contact': {
 'first_name': name,
 'email': email
            }
          }
        })
        .then((httpResponse) => {
 if (httpResponse.ok) {
 return httpResponse.json();
            } else {
 return Promise.reject("Fetch did not succeed");
            }
        })
        .then((json) => console.log(json.someKey))
        .catch(err => console.log(err));
}