I'm looking to build a banking/budgeting app to use myself/use for a portfolio project. I am relatively new to using API's but have been learning Javascript/HTML/CSS fr around a year now.
I know this questions has been asked many times on here, but none of the responses seem to help my situation.
Iam trying to retrieve some bank account information using Natwest's Bank of API's - https://developer.sandbox.natwest.com/api-catalog/1735631/getting-started They allow you to generate a test App to test the API with some mock values.
I managed to achieve the responses successfully using terminal and curl, following the pages suggestions, but when translating this to Javascript I have been getting nowhere.
I am trying to get the first response, and get the above error. I have installed mkcert, to generate a trusted SSL - which appears to have been successful: enter image description here
I am using http-server, which initially generates a server hosted on: https://127.0.0.1:8081/, bringing up an error: ERR_CERT_COMMON_NAME_INVALID. I change this to https://localhost:8080, and this error is resolved.
Is this an error with Natwest not allowing a response or is the problem on my end?
Thanks in advance!
const CLIENT_ID = "dT03BZM7QTxKPsbrh4jkj09UO-D5tgpJc_8sG8VLyi8=";
const CLIENT_SECRET = "KdARr1dBr6r0fFjIB5246OQSLEGhzYB8EpHgQDaKgxw=";
fetch("https://ob.sandbox.natwest.com/token", {
body: `grant_type=client_credentials&client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}&scope=accounts`,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
method: "POST",
})
.then((response) => console.log(response))
.catch((error) => console.log(error));