All right, so web development is something new to me so I wasn't exactly sure what I needed to provide so I want to also provide a link to the repo that contains this code: Excel Add-In Repo
Problem:
Right now, I'm in the process of building an Excel Add-In using the new JavaScript API. I am currently using the "React Framework" task pane template that is provided by the yo office generator
. Inside of my add-in I want to make a web request to the following URL: https://www.sec.gov/files/company_tickers.json
Every time I make the request it returns an error. Here is how the request look:
// I assign this function on line 115.
fetchCikNumbers = async () => {
try {
// Make a new HTTP Request.
var xhr = new XMLHttpRequest();
// Define the Method and URL.
xhr.open('GET', `https://www.sec.gov/files/company_tickers.json`);
// Maybe set the "Access-Control" header?
// xhr.setRequestHeader('Access-Control-Allow-Origin','*');
// Print the Text to the Console.
xhr.onload = function (e) {
console.log(this.responseText);
console.log(e);
}
// Send the Request.
xhr.send();
} catch (error) {
console.error(error);
}
}
Initially, this is the error I got:
Here is what I've tried:
- I looked online and they mentioned I should add the URL to a
<AppDomain></AppDomain>
tag in my manifest file. However, that didn't fix the issue either. - I added
Access-Control-Allow-Origin
to my headers when making a request. When I do that, it just says it can't find the identified Resource URI.
Additional Notes:
I'm just not sure what it could be, and to make things even weirder if I make a normal call to a regular API like Alpha Vantage, I have no issues. Now, I will say that the SEC
has weird pages that don't seem to be formatted correctly. For example, even though it points to a JSON URL the data doesn't seem like it's properly coded as such.