Why does my JavaScript get a “No 'Access-Control-Allow-Origin' header is present on the requested resource” error when Postman does not?

Why does my JavaScript get a “No 'Access-Control-Allow-Origin' header is present on the requested resource” error when Postman does not?

I am trying to do authorization using&nbsp;<a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a>&nbsp;by connecting to the&nbsp;<a href="http://en.wikipedia.org/wiki/Representational_state_transfer#RESTful_web_services" target="_blank">RESTful</a>&nbsp;<a href="http://en.wikipedia.org/wiki/Application_programming_interface" target="_blank">API</a>&nbsp;built in&nbsp;<a href="https://en.wikipedia.org/wiki/Flask_%28web_framework%29" target="_blank">Flask</a>. However, when I make the request, I get the following error:

I am trying to do authorization using JavaScript by connecting to the RESTful API built in Flask. However, when I make the request, I get the following error:

XMLHttpRequest cannot load http://myApiUrl/login. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

I know that the API or remote resource must set the header, but why did it work when I made the request via the Chrome extension Postman?

This is the request code:

$.ajax({
    type: "POST",
    dataType: 'text',
    url: api,
    username: 'user',
    password: 'pass',
    crossDomain : true,
    xhrFields: {
        withCredentials: true
    }
})
    .done(function( data ) {
        console.log("done");
    })
    .fail( function(xhr, textStatus, errorThrown) {
        alert(xhr.responseText);
        alert(textStatus);
    });



Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Postman Tutorial | Postman Crash Course for Beginners | Learn API Testing using Postman

A Postman tutorial walking you through the most important steps inside the Postman App. Begin writing API tests now!&nbsp;&nbsp;

How to Install Postman in Linux

<img src="https://linux4one.com/wp-content/uploads/2019/04/How-to-Install-Postman-in-Linux.jpg">

Sending JWT token in the headers with Postman

I'm testing an implementation of JWT Token based security based off the following&nbsp;<a href="https://auth0.com/blog/2014/01/07/angularjs-authentication-with-cookies-vs-token/" target="_blank">article</a>. I have successfully received a token from the test server. I can't figure out how to have the Chrome POSTMAN REST Client program send the token in the header.