Hi I wrote the code to send a post api to my solution. However, there is an error saying base64.encode is not defined.
Is there any other code that i can encode the username and password?
import {fetch} from ‘wix-fetch’;
export function postCurrentPayment(amount){
let url = “http://localhost:53187/api/donation”;
let username = ‘1’;
let password = ‘2323232’;
let headers = {
‘Authorization’: 'Basic ’ + base64.encode(username + “:” + password)
};
let options = {
method:‘POST’,
headers: headers
}
return fetch(url, options)
.then((httpResponse) => {
if (httpResponse.ok)
{
return httpResponse.json();
}
// Add code to check the response
});
}