Jump to content

Vathson

Member
  • Posts

    3
  • Joined

  • Last visited

Reputation Activity

  1. Like
    Vathson got a reaction from Beyondspace in 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; } $.ajax({     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) {         console.log(data)     } }); ..
×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.