0

I'm reading a documentation for api but it's example is in python. Here's the code:

import http.client

conn = http.client.HTTPSConnection("api.sportradar.us")

conn.request("GET", "/mma-t1/schedule.xml?api_key={your_api_key}")

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

But I'm using node. I tried to convert above code to this:

import request from 'request';

const key = Meteor.settings.sportradar.mma_v1;
const conn = `api.sportradar.us/mma-t1/schedule.xml?api_key=${key}`;

request(conn, (err, res, body) => {
  console.log('error:', err);
  console.log('statusCode:', res && res.statusCode);
  console.log('body:', body);
});

but I'm getting an error: Invalid URI.

The response will be in XML if that matters.

Can someone help please?

1 Answer 1

1

In node you usually need to append http or https to the uri.

Sign up to request clarification or add additional context in comments.

2 Comments

That's it! Thank you.
Yep! I was waiting out the 10min before I could accept your answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.