From the course: Build a JavaScript AI App with React and the OpenAI API

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Pass the response to the weather data request

Pass the response to the weather data request

- [Instructor] All right, at this point, the OpenAI API is able to turn the user question into location data and then we can turn that location data into the correctly formatted location string. The next step is to pass that location string onto use API request here so that when we request the coordinates for a location, we're passing in that string. To do that, I'll set up a new constant with an object inside it and in that object, I'll have the location string and I'll also have any other information I think might be pertinent 'cause you'll remember we got a bunch of information from the OpenAI API, not just the location data. So, I'll set up a new constant here, call it promptData, and I'll set it equal to an object, and then inside that object I'll set up locationString, and I'll set that to the locationString function we just created. Then I'll say units, and I'll set that to promptRes units that would be metric or…

Contents