Find degrees between two points

This is based on SFML where zero degrees is right -> (+x axis)

#include <cmath>

float angleBetweenVectors(const sf::Vector2f& p1, const sf::Vector2f& p2)
{
    float angleInRadians = atan2(p1.y - p2.y, p1.x - p2.x);
    float angleInDegrees = (angleInRadians / M_PI) * 180.0;
    return angleInDegrees < 0 ? angleInDegrees + 360 : angleInDegrees;
}

When the angle goes negative, we add 360 to normalise it.

No Recursion Required

Fetching all the records from a multi page API endpoint without recursion back to the same function. Example in JavaScript.

const getAllProducts = async () => {
  // data and options is set elsewhere in this case
  data['maxRecords'] = 250;
  let res;
  let products = [];
  let page = 1;

  do {
    res = await axios.post(url, data, options);
    products = [...products, ...res.data.pageRecords];
    count = res.data.pageRecords.length;
    data['page'] = page + 1;
  } while (count === data['maxRecords'])

  return products;
}