The question:
I think I have the API proxi url that I can use to bring the content to the front end with js with this instructions (Postman API | Postman Learning Center). Do I still need the bearer token and where do I declare the x-rates?
A snippet would be awesome.
I need the postman send request results to display on the front end, using plain javascript.
(don’t suggest node js I can’t use it for this particular project).
Details
Directly accessing the api w/the Postman snippet doesn’t work, and it would be a security issue.
How I found the problem:
I tried both an async and reg function call using the provided postman snippet
CORS is an issue, but also I need a way to do this w/out displaying the tokens to the public
I’ve already tried:
Used a live website page so the code wouldn’t be on a local desktop, but it looks like I can’t access the API directly this way.
update
I created a mock server and an api key, and x-api key. A pointer to a code snippet with them would be awesome
Also this is the code I would be using, based on the snippet in postman. (REDACTED TOKENS), but using the api key, would I still need the bearer token, I’d think not. and would the;
X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset be delcared in the api string w/the request
"use strict";
function asyncCall() {
var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer REDACTED");
myHeaders.append("Cookie", "guest_id= REDACTED");
var requestOptions = {
method: 'GET',
headers: myHeaders,
redirect: 'follow'
};
fetch("PMAK-62a0d9932d337033e1722c80-3c9250198d077e8d79bb72f1c6e55e427dhttps://api.REDACTED=attachments,id,text&user.fields=id,name,username", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
/*
try{
const response = await fetch("https://api.REDACTEDmax_results=10&tweet.fields=attachments,id,text&user.fields=id,name,username", requestOptions);
const responseText = await response.text();
console.log(responseText);
}
catch (error) {
console.log('error', error);
}
*/
}
asyncCall();
Thank you