Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Testing IONOS cloud, parsing headers, cURL, node
# This approach works. ✅
# The idea is possibly cURL is tolerant to invalid headers.
# How to test:
# 1. Install cURL https://curl.haxx.se/
# 2. In your terminal copy and paste:
curl -v -H 'X-TOKEN: 1234' 'https://cloudpanel-api.ionos.com/v1/servers'
/*
This does not work because nodejs cannot parse the headers. 🐛
How to reproduce:
1. Install nodejs https://nodejs.org/de/
https://nodejs.org/en/
2a. Try to you use your company's module with node: https://github.com/1and1/oneandone-cloudserver-sdk-nodejs
2b. `npm install superagent` and run this script with node
*/
const superagent = require("superagent");
const endpointUrl = "https://cloudpanel-api.ionos.com/v1";
const token = "1234";
superagent
.get("https://cloudpanel-api.ionos.com/v1/servers")
.set("X-TOKEN", token)
.type("json")
.accept("json")
.then(res => console.log("res", res))
.catch(err => console.error("err", err)); // ⬅️⚠️ it will not parse headers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.