-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: self.client.sendRequest is not a function #439
Comments
@AldoCF96 I figured it out! Check which access token you are passing to your client. |
@boxman0617 Hi, thanks for your answer! I feel more confident using this client with TypeScript. It has been absolutely horrible to figure out the import and type definitions because the default export wouldn't work lol. Though I'm still having the same issue. weird thing is that with a pk token, it works fine on my already existing JS project with the exact same code copy pasted. I wouldn't have figured out the sk token part, but it still returns the same error on my new project. Is there anything else to do? |
@busybox11 The imported client is probably wrong, I am running this in a Remix.js project, in esm. I faced the same error, and browsing the code to see which file contains the correct method, for my case changing the first line to: did the trick, it is now working. effectively there is no |
Yeah that's what I did. I believe my error came from the fact that I was using bun (yeah I know. sorry) Although the token thing didn't help. This is weird. Doing the request manually with the same token works. The library is probably doing something wrong - looks like many things are wrong with it lol |
same thing with next js,
|
This error appears went trying to make a geocode call:
TypeError: self.client.sendRequest is not a function
at MapiRequest.send (mapi-request.js:160:1)
at MapboxApi (mapbox-api.tsx:15:1)
at renderWithHooks (react-dom.development.js:16141:1)
at mountIndeterminateComponent (react-dom.development.js:20838:1)
at beginWork (react-dom.development.js:22342:1)
at beginWork$1 (react-dom.development.js:27219:1)
at performUnitOfWork (react-dom.development.js:26395:1)
at workLoopSync (react-dom.development.js:26303:1)
at renderRootSync (react-dom.development.js:26271:1)
at performSyncWorkOnRoot (react-dom.development.js:25924:1)
this is the code:
import mbxClient from "@mapbox/mapbox-sdk/lib/classes/mapi-client"
import mbxGeocoding from "@mapbox/mapbox-sdk/services/geocoding"
const baseClient = new mbxClient({
accessToken:
"pk.eyJ1IjoiYWlybWF0cml4NjQ3IiwiYSI6ImNqeG5wZXNlajBoMGUzbm82ZjcweWF0OHkifQ.4iv7e_Bep3UXFbhp7nUqHQ",
})
const geocodingClient = mbxGeocoding(baseClient)
export interface MapboxApiProps {}
export function MapboxApi(props: MapboxApiProps) {
geocodingClient
.forwardGeocode({
query: "Paris, France",
limit: 2,
})
.send()
.then((response) => {
const match = response.body
console.log(match)
})
}
export default MapboxApi
The text was updated successfully, but these errors were encountered: