Get current weather in a city in chosen units
npm i @superfaceai/one-sdk
const { SuperfaceClient } = require('@superfaceai/one-sdk');
// You can manage tokens here: https://superface.ai/insights
const sdk = new SuperfaceClient({ sdkAuthToken: '<< Login to get your token >>' });
async function run() {
// Load the profile
const profile = await sdk.getProfile('weather/current-city@1.0.3');
// Use the profile
const result = await profile
.getUseCase('GetCurrentWeatherInCity')
.perform({
city: 'Prague, Czech Republic',
units: 'C'
}, {
provider: 'mock'
});
// Handle the result
try {
const data = result.unwrap();
console.log(data);
} catch (error) {
console.error(error);
}
}
run();
{
"city": "Prague, Czech Republic",
"units": "C"
}
{
"temperature": 9,
"feelsLike": 8,
"description": "Partly cloudy"
}