Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

Ajax API call - 401 Unauthorized Error



I'm creating a GET request from my square space site to Big commerce using ajax API call. But facing 401 unauthorized error.

I've attached my code I'm using right now - hope someone can help me out of this problem.

const username = "username";
const password = "password";

function make_base_auth(user, password) {
    var tok = user + ':' + password;
    var hash = btoa(tok);
    return "Basic " + hash;
    url: "https://api.bigcommerce.com/stores/{store-hash}/v3/catalog/products",
    async: true,
    crossDomain: true,
    beforeSend: function(xhr) {
        xhr.setRequestHeader('Authorization', make_base_auth(username, password));
    headers: {
        "X-Auth-Client": "secret-key",
        "X-Auth-Token": "token",
        "Content-Type": "application/json",
        "cache-control": "no-cache",

    type: "GET",
    dataType: "jsonp",

    success: function(data) {


Link to comment
  • Answers 0
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

Popular Days

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...