var url = 'https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token'; var params = 'grant_type=client_credentials&client_id=Fastapi&client_secret=wojuoB7Z5xhlPFrF2lIxJSSdVHCApEgC'; // METHOD 1 (fetch POST) let args = { "url": "https://192.168.1.3:10002/realms/API.Server.local/protocol/openid-connect/token", "options": { "method": "POST", "headers": { "Content-Type": "application/x-www-form-urlencoded" }, "body": params } }; if (args.options.body && typeof args.options.body !== 'string') args.options.body = JSON.stringify(args.options.body); fetch(args.url, args.options).then(response => response.json()).then(data => {console.log('fetchJson success'); console.log(data);}).catch((err) => {console.log('fetchJson error');console.log(err);})